Usage¶
Planning Monthly Planet Composites¶
plaknit plan queries Planet's Data/STAC API, filters PSScene candidates, tiles the AOI, and picks the smallest monthly set that meets both coverage and clear-observation targets. Planning now only writes/prints a plan; ordering is handled separately by plaknit order.
1 2 3 4 5 6 7 8 9 10 11 12 | |
The summary table shows candidate/selected scenes, achieved coverage, and clear observation depth.
Planet limits STAC/Data AOI intersections to 1,500 vertices, so the planner automatically simplifies uploaded AOIs (while preserving topology) until they fit under that threshold and logs how many vertices were removed. Scenes that lack clear/cloud metadata are ignored during scoring so plans only rely on scenes with reliable quality fields.
If you already saved a plan JSON/GeoJSON, submit matching orders later without recomputing coverage:
1 2 3 4 5 6 | |
Order output arguments:
- --plan: Plan JSON/GeoJSON that defines which scene IDs (and months) are ordered.
- --aoi: Geometry used for clipping; the clip AOI is applied to delivered scenes.
- --sr-bands: Chooses 4- or 8-band SR bundle; changes the bands in each scene.
- --harmonize-to: sentinel2 harmonizes to Sentinel-2; none keeps native SR.
- --order-prefix: Prefix for order name and archive filename; batches append _2, _3, etc., and ZIPs end with .zip.
- --archive-type: Delivery archive format; Planet currently supports zip only.
- --single-archive / --no-single-archive: One ZIP per order vs per-scene files.
- -v / -vv: Verbose logging for submissions and retries; no change to output.
The order subcommand loads the stored plan, clips to the provided AOI, and
submits orders (chunked at 100 scenes max) while reporting the returned order
IDs. If Planet reports any “no access to assets …” errors, plaknit order
automatically drops the inaccessible scene IDs and retries so the remaining
items can still be delivered.
Mosaic¶
plaknit mosaic ships with a CLI that is best run in High-Performance Computing Environments. Install the package into the same
environment that contains GDAL and Orfeo Toolbox, then run the mosaic workflow:
1 2 3 4 5 6 7 | |
You can call the module directly with python -m plaknit.mosaic
if you prefer to pin the interpreter. The progress display stays minimal with
four bars: Radiometry (optional) → Mask tiles → Binary mask → Mosaic
(shown when rich is installed).
Required arguments¶
--inputs / -il: One or more GeoTIFFs or directories. Directories are expanded to all.tiffiles.--output / -out: Destination path for the final mosaic.
Optional arguments¶
--udms / -udm: UDM rasters (files or directories). Omit only when--skip-maskingis supplied.--skip-masking: Use the provided inputs directly without applying the gdal-based UDM mask.--harmonize-radiometry: Enable graph-based radiometric harmonization (Harmoni-Planet style) before masking/projection.--metadata-jsons / -meta: Metadata JSON files/directories used to build the overlap/time graph; required only when--harmonize-radiometryis enabled.--sr-bands: Surface reflectance bundle size (4 or 8).--target-crs: Optional CRS override (for exampleEPSG:32735) applied to every tile before mosaicking.--workdir / --tmpdir: Override the locations used for intermediate strips and OTB scratch files. Defaults are automatically managed temp directories.--jobs: Number of parallel masking workers (defaults to 4).--ram: RAM hint for OTB in MB (defaults to 131072).-v/ -vv: Increase logging verbosity.
By default, plaknit mosaic now checks every input CRS and reprojects
non-matching rasters to a single target CRS before running OTB. The target is
chosen from the majority CRS across inputs; ties are resolved by choosing the
CRS from the tile nearest the geographic center of the stack.
Raster/vector distance¶
Calculate a distance surface from any supported vector source on a projected raster grid:
1 2 3 | |
The output uses the template grid and stores distances in its CRS map units.
Install plaknit[gpu] and pass backend="gpu" to use CuPy.
Random Forest classification¶
plaknit classify trains and applies a Random Forest to multi-band stacks. The CLI
accepts one or more --image paths; you can pass multiple aligned GeoTIFFs
directly (or repeat --image) or build a VRT first (gdalbuildvrt stack.vrt band1.tif band2.tif ...).
Use --binary-out during prediction to output individual binary masks for each class.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | |
Python API (same engine, useful for notebooks):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | |
Training samples pixels under each polygon window-by-window to keep RAM in
check. training_buffer_meters includes surrounding pixels in the training
sample while preserving the source geometry label. Prediction streams over
raster blocks (--block-shape overrides block size) so it works on laptops and
HPC nodes alike; add --jobs to parallelize block prediction with multiple
worker processes (watch for CPU oversubscription if the model was trained with
n_jobs > 1). Classified rasters store numeric
class IDs; inspect rf.label_decoder to map each ID back to its label. Training
holds out a fraction of samples for evaluation; prediction logs the holdout
confusion matrix plus band importance from the stored model and writes
*_metrics.txt next to the output raster (raw + smoothed confusion matrices and
misclassified validation IDs when available). See docs/hpcenv.md
for a Singularity/Apptainer job template that binds the stack,
labels, model, and venv for training + prediction.
Boosted Regression Tree (BRT) Ensemble classification¶
plaknit brt trains and applies Boosted Regression Tree (BRT) models to multi-band stacks. Training labels use Bernoulli coding: presence is 1 and absence is 0. Ensemble prediction writes unweighted mean probability and confidence-interval rasters.
Training¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | |
Prediction¶
1 2 3 4 5 6 | |
Python API¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |
Key Features¶
- Ensemble Diversity: Each model in the ensemble is trained with a different random seed, ensuring diverse predictions.
- Unweighted Summaries: Class probabilities are averaged equally across all models, with t-based lower and upper confidence bounds.
- Model Assessment: Holdout ROC AUC is recorded for each member in ensemble metadata and optional model-summary CSV output.
- Predictor Ranking: Optional feature-importance CSVs summarize each input band's unweighted split importance across the ensemble.
- GPU Support: Add
--gpuflag to use XGBoost's GPU acceleration (requiresplaknit[gpu]installation); gracefully falls back to CPU if unavailable. - Probability Output:
mean_probabilities.tif,lower_probabilities.tif, andupper_probabilities.tifare written to the output directory. One-member ensembles write only the mean raster. - Spatial Sampling: Use
--grid-sizeto spatially thin training samples for improved generalization.
Hyperparameter Guide¶
--n-models: Number of models in the ensemble (5-15 recommended). More models increase ensemble diversity.--n-estimators: Boosting rounds per model (100-500). More rounds capture complex patterns but risk overfitting.--max-depth: Tree depth (4-8). Shallower trees prevent overfitting; deeper trees capture interactions.--learning-rate: Step size for boosting updates (0.01-0.3). Lower rates are more conservative.--subsample: Fraction of samples per round (0.5-1.0). Lower values add stochasticity and reduce overfitting.--colsample-bytree: Fraction of features per tree (0.5-1.0). Lower values increase diversity.--test-fraction: Holdout fraction for evaluation (0.2-0.4). Per-model accuracy is recorded as a diagnostic.
Use --feature-importance-out predictor_importance.csv during ensemble prediction to write unweighted per-band summary statistics. mean_importance is a relative split-contribution ranking, not a linear coefficient or a causal effect.
Comparing BRT Ensemble vs Random Forest¶
| Feature | BRT Ensemble | Random Forest |
|---|---|---|
| Model Type | Gradient boosting | Bagging (ensemble) |
| Training Time | Medium | Fast |
| Prediction Accuracy | High | High |
| Interpretability | Low | Medium |
| GPU Support | Yes | No |
| Hyperparameter Tuning | More involved | Less involved |
| Ensemble within Ensemble | Yes (multiple BRTs) | Yes (multiple trees) |
Both classifiers are suitable for PlanetScope data; choose BRT for potentially higher accuracy on complex scenes, or Random Forest for faster training with good accuracy.