API reference
Data acquisition
Download raw imagery + ancillary layers from public + commercial providers.
| fetch.fetch_sentinel_data | Fetch imagery for any supported mission and provider. |
| fetch.resolve_aoi | Resolve an AOI spec to a WGS84 bbox [lon_min, lat_min, lon_max, lat_max]. |
| fetch.resolve_aoi_geometry | Return the AOI’s true polygon(s) in WGS84, or None. |
| fetch.MISSION_PROFILES | |
| fetch.get_profile | Return the profile for a mission, or raise a clear error. |
| fetch.get_provider_config | Return provider-specific config for a mission, or raise a clear error. |
| fetch.validate_query | Validate an AOI + optional time_range early, before any provider |
| fetch.fetch_earthsearch | Earth Search STAC + AWS Open-Data COGs (anonymous HTTPS). |
| fetch.fetch_planetary_computer | Microsoft Planetary Computer STAC + Azure blob (anonymous, SAS-signed). |
| fetch.fetch_direct_http | Direct-HTTP / S3 tile-indexed fetcher for missions outside STAC. |
| fetch.fetch_planet | PlanetScope via the Planet Data + Orders APIs (requires PL_API_KEY). |
| fetch.fetch_sentinelhub | Original Sentinel Hub Process API path. Requires SH credentials. |
Pre-processing: fuse, tile, export
Turn raw fetched imagery into AI-ready data cubes.
| preprocessing.fuse_response_tiffs | Reproject + resample selected bands from each input onto a common grid |
| preprocessing.tile_geotiff | Tile a multi-band GeoTIFF into AI-ready patches with a chosen split strategy. |
| preprocessing.clip_to_geometry | Set pixels outside the polygon(s) to NaN in a GeoTIFF, in place. |
| preprocessing.AVAILABLE_AUGMENTATIONS | |
| preprocessing.LazyTileDataset | Lazy on-the-fly tile sampler reading from a multi-band cube. |
| preprocessing.geotiff_to_zarr | Re-pack a multi-band GeoTIFF into a chunked Zarr array. Zarr is |
| preprocessing.export_to_zarr | Export GeoTIFF tiles and metadata to a Zarr dataset. |
| preprocessing.export_to_lmdb | Convert all .tif tiles in tiles_dir to LMDB. |
| preprocessing.export_temporal_cube_chunk | Export one SLURM-array chunk of a multi-temporal patch cube to Zarr, |
| preprocessing.merge_chunks | Concatenate {split}_chunk*.zarr (written by concurrent |
| preprocessing.read_patch_meta | Decode the metadata JSON for patch idx of an exported store. |
Band math + metadata
Per-band normalisation, cloud masking, mission-aware NaN handling.
| preprocessing.normalize_band | Normalize a band to [0, 1] by linear stretch on its own extrema. |
| preprocessing.compute_ndvi | NDVI = (NIR - RED) / (NIR + RED). |
| preprocessing.compute_ndwi | NDWI (McFeeters 1996) = (GREEN - NIR) / (GREEN + NIR). |
| preprocessing.compute_dem_gradient_magnitude | Per-pixel terrain slope proxy: sqrt((dy)^2 + (dx)^2) in metres. |
| preprocessing.cloud_mask | Build a boolean cloud / shadow mask from a quality band. |
| preprocessing.infer_band_kind | Return the kind inferred from a band name suffix. |
| preprocessing.get_band_kind | Three-tier lookup for a band’s kind. |
| preprocessing.get_band_norm | Three-tier lookup for a band’s normalisation recipe. |
| preprocessing.apply_band_norm | Apply a normalisation recipe to a 2-D band array. |
| preprocessing.split_mission_band | Split a fused-cube band name into (mission, bare_band). |
| preprocessing.select_bands | Subset bands from a fused cube and write a clean GeoTIFF. |
| preprocessing.write_label_uint8 | Re-write a single-band label GeoTIFF with a clean nodata convention. |
| preprocessing.BAND_PRESETS |
ML / DL helpers
Downstream task helpers built on top of the cubes.
| ml_dl.TinyUNet | Two-level U-Net for binary per-pixel segmentation. |
| ml_dl.WaterUNet | Four-level U-Net with batch-norm for water-class segmentation. |
| ml_dl.harvest_pixels | Walk a LazyTileDataset and return (X, y) for one split. |
| ml_dl.balance_pos_neg | Random under-sampling of the majority (negative) class. |
| ml_dl.tune_threshold | Sweep predict_proba thresholds; return the F1-optimal one. |
| ml_dl.binary_pixel_metrics | Per-pixel binary confusion-matrix metrics. |
| ml_dl.predict_with_threshold | Apply proba >= threshold to a sklearn-compatible classifier. |
| ml_dl.full_metrics | Run a torch segmentation model over a DataLoader and aggregate. |
| ml_dl.class_filtered_indices | Return tile indices where the binary label has at least min_pos_frac. |
| ml_dl.pick_class_balanced_tiles | Pick n_show tile indices that span a positive-fraction range. |
| ml_dl.YOLOBuildingDetector | One-stop wrapper for the notebook-03 workflow. |
| ml_dl.polygons_to_yolo_tiles | Cut tile_px x tile_px tiles from the AOI window of scene_path, |
| ml_dl.train_yolo_detector | Run Ultralytics YOLO training with the arguments the notebook needs. |
| ml_dl.validate_yolo_model | Run Ultralytics validation on a held-out split. |
| ml_dl.box_iou | IoU between two axis-aligned boxes (xmin, ymin, xmax, ymax). |
| ml_dl.draw_yolo_boxes | Overlay YOLO-format bounding boxes from lbl_path onto img. |
| ml_dl.pick_tiles_with_boxes | Pick up to k tile PNGs from image_dir whose matching label |
| ml_dl.write_yolo_data_yaml | Write the data.yaml Ultralytics expects at the YOLO directory root. |
| ml_dl.yolo_lines_to_pixel_boxes | Decode YOLO-format label rows into pixel-space (x0, y0, x1, y1) boxes. |
Visualisation
Scene, tile, and split-layout figures used across the notebooks.
| viz.open_response | Open a fetched scene and return its array + metadata as a 7-tuple. |
| viz.print_response_summary | Print a concise one-screen summary of a fetched scene. |
| viz.stretch01 | Per-band percentile stretch to [0, 1]; NaN stays NaN. |
| viz.joint_rgb | Joint-percentile stretch across three bands -> (H, W, 3) RGB. |
| viz.show_bands | Plot every band as a small subplot in a balanced grid. |
| viz.show_rgb | True-colour-ish RGB composite from named bands. |
| viz.decode_scl | Decode the Sentinel-2 L2A SCL classification into a boolean mask. |
| viz.decode_bqa | Decode the Landsat BQA / QA_PIXEL band into a boolean mask. |
| viz.plot_cloud_pair | Three-panel cloud diagnostic: imagery / raw QA / decoded mask. |
| viz.count_tiles | Count .tif files in train/, val/, test/ under out_dir. |
| viz.open_tile | Open one tile and return (array, descriptions, tags). |
| viz.best_demo_tile | Pick the tile that best illustrates a given NaN-handling mode. |
| viz.describe_tile | Pretty-print a one-tile property overview as a set of small tables. |
| viz.tile_grid_overlay | Overlay the tile grid on a base image, on the matplotlib ax. |
| viz.visualize_nan_handling_modes | Render the canonical 3-row ‘how do the NaN modes differ?’ figure. |
| viz.plot_split_layout | Overlay the tile-bucket assignments for method on imagery. |
| viz.city_panel | One city panel for the regions cross-AOI split visualisation. |