Introduction
mapcv turns a region, imagery and labels into a ready-to-train remote-sensing dataset. You describe where (a longitude/latitude box or polygons), what imagery (XYZ map tiles, your own GeoTIFF or COG, Sentinel-2, or Google Earth Engine) and, optionally, what to label (vector features in GeoJSON, KML, GeoPackage, Shapefile, GeoParquet or straight from OpenStreetMap, or a label raster). mapcv reads the imagery, puts the labels on exactly the same pixel grid, cuts fixed-size patches for the task you choose, and writes them with a manifest and leakage-safe train/val/test splits.

Patches and building masks made by mapcv (imagery: Beeldmateriaal Nederland, CC BY 4.0; labels: © OpenStreetMap contributors).
Why it exists
Section titled “Why it exists”Building a dataset from geospatial imagery usually means a one-off script: stitching tiles or windows by hand, fighting coordinate systems, and a split that quietly leaks neighbouring pixels between train and test. mapcv is a data-creation-first tool: one YAML file, a few commands, and the result is plain files on disk.
- Fast Rust core. The heavy lifting is Rust (tile math and fetching, GeoTIFF reading and writing, rasterizing, patch encoding) behind a small Python layer.
pip install mapcvis the whole setup for XYZ tiles and GeoTIFF/COG. - Correct by default. Masks follow GDAL’s exact rules, labels are reprojected into the imagery’s own CRS, class IDs are stable, and the default split keeps spatially close patches together.
- Honest estimates.
mapcv plantells you how many tiles, patches, megabytes and how much memory a run needs before anything is downloaded. - Resumable. Progress is saved as the run goes and whenever it stops. If a run stops, the same command continues it, and the result is byte for byte the same.
How this compares with scripts, TorchGeo, Raster Vision and geoai: Why mapcv.
Who it is for
Section titled “Who it is for”- Computer-vision and ML researchers who need a dataset for a specific place and task, without becoming GIS specialists.
- Remote-sensing practitioners who want multispectral Sentinel-2 or their own GeoTIFFs as plain arrays or georeferenced patches.
- Anyone teaching or benchmarking who needs a dataset that can be regenerated from a config file.
What you get
Section titled “What you get”| Output | What it is |
|---|---|
Images/patch_0000000.png |
RGB patch (.jpg optional), a bands-first .npy array (Sentinel-2, multiband GeoTIFFs) or a georeferenced .tif |
Masks/patch_0000000.png |
uint8 mask with the same name: 0 = background, 1… = class IDs, 255 = no imagery (ignore) |
manifest.json |
Source, bands, CRS, affine transform, class map, sampler settings and per-patch statistics |
splits/train.txt, val.txt, test.txt |
One image filename per line |
splits/<percent>/labeled.txt |
Optional labeled/unlabeled subsets of train for semi-supervised learning |
patches.geojson |
Every patch’s footprint, file name and split, to open in QGIS |
With task: detection, each label feature becomes a box instead: COCO JSON per split, YOLO label files and an Ultralytics dataset.yaml replace the masks (see Object detection datasets). With task: instance, each feature becomes its own binary mask instead: COCO JSON per split with RLE masks, and optionally a 16-bit instance-ID PNG per patch (see Instance segmentation datasets). With task: classification, each patch gets one label or a set of labels from the share of it each class covers instead: a labels.csv and labels.json replace the masks (see Patch classification datasets). With task: change and two imagery sources, each patch is a before/after pair with a change mask, in LEVIR-CD’s A/, B/, label/ folders (see change). With task: regression, each pixel’s target is a float read from a raster of values such as canopy height (see continuous values). Segmentation and regression datasets can also sample several imagery sources on one grid, such as two dates or imagery plus a DEM.
Details: Dataset format.
What mapcv does not do
Section titled “What mapcv does not do”- No resampling between grids. Imagery is read on its own pixel grid. Several sources or mosaic tiles must share a CRS and line up pixel for pixel (a coarser source may be a whole multiple); mapcv does not warp one grid onto another.
- No private stores. Remote GeoTIFF, STAC and EOPF URLs must be public; signed URLs and private buckets are not supported.
- One Sentinel-2 scene per run.
stac_cogandeopf_zarrpick one item; Earth Engine can composite a collection. - Standard XYZ tiles only. XYZ sources must serve 256 × 256 tiles.
- No imagery of its own. mapcv fetches what your config names; Providers & licensing lists each source’s license and credit line.