Skip to main content

mapcv logo

mapcv

Turn imagery and labels into ready-to-train remote-sensing datasets, fast.

Package version Supported Python versions License Downloads Documentation Test coverage DOI OpenSSF Best Practices OpenSSF Scorecard Ruff


Aerial patches over Amsterdam and the same patches with mapcv's building masks
Patches and building masks made by mapcv. Imagery: Beeldmateriaal Nederland (CC BY 4.0); labels: © OpenStreetMap contributors.

Statement of Need

Building a machine-learning dataset from geospatial data usually means a one-off script: fetch or read imagery, burn label polygons, cut patches, split. Done carefully, it handles coordinate systems, pixel-centre rules, NoData, memory, crashes and spatial leakage between train and test; done quickly, it silently gets them wrong. Existing geospatial tools are analysis-first or sample data at training time. mapcv is data-creation-first: one YAML config, and the result is plain files on disk, checked against reference implementations.

  • Imagery: XYZ tiles, your own GeoTIFF/COG (local, https://, s3://), Sentinel-2 (EOPF Zarr, or COGs found in a STAC catalog, with cloud masking), Google Earth Engine; several sources on one grid.
  • Labels: GeoJSON, KML, GeoPackage, Shapefile, GeoParquet, OpenStreetMap, or a label raster.
  • Tasks: semantic segmentation, object detection (COCO/YOLO), instance segmentation (COCO RLE), patch classification, change detection and regression.
  • Output: PNG/JPEG/GeoTIFF/NPY patches, a manifest, leakage-safe splits, and exports to Hugging Face Parquet, WebDataset, Zarr and TerraTorch; mapcv.data.MapcvDataset loads any of them for PyTorch.
  • Correct and fast: masks follow GDAL's exact rules; a careful rasterio script, GDAL's tools and leafmap produce the same patches, 1.5–34× more slowly (benchmarks). Interrupted runs resume byte for byte; memory stays bounded on any region size.

Why not a script, TorchGeo, Raster Vision or geoai? See Why mapcv.

Installation

pip install mapcv

Requires Python 3.10 or newer. One pre-built wheel per platform (Linux x86-64 and aarch64 with glibc or musl, macOS, Windows) covers every supported Python version; other platforms build from source and need a Rust toolchain.

Optional extras: mapcv[zarr] (Sentinel-2 EOPF Zarr, Python 3.10–3.13), mapcv[gee] (Google Earth Engine), mapcv[parquet] (GeoParquet labels), mapcv[export] (Hugging Face Parquet) and mapcv[mcp] (the MCP server for AI agents). XYZ tiles, GeoTIFF/COG and STAC need none of them.

Quick start

1. Scaffold a config file

mapcv init my_dataset.yaml

In a terminal this asks a few questions (imagery, area, labels, patches) and writes a working config; mapcv init my_dataset.yaml --template xyz writes a commented example to fill in instead. Everything else has sensible defaults.

Note: XYZ sources must return standard 256x256 pixel tiles. mapcv does not provide imagery; see PROVIDERS.md for how it treats imagery and how to credit each source.

2. Generate the dataset

mapcv generate my_dataset.yaml

This fetches tiles, rasterizes labels, extracts patches, and writes everything to the output directory specified in your config.

3. Re-split an existing dataset (optional)

mapcv split ./output --test-ratio 0.15 --val-ratio 0.10

Re-runs the train/val/test split from the existing manifest.json without re-downloading anything.

4. Prepare it for training and sharing (optional)

mapcv stats ./output     # per-band mean/std and class weights over train → stats.json
mapcv card ./output      # README.md dataset card with Hugging Face metadata
mapcv verify ./output --write-checksums

Bring your own imagery

Your own GeoTIFF or Cloud Optimized GeoTIFF (a local file, an https:// URL, a public s3:// object, or a glob pattern such as tiles/*.tif that reads a folder of local tiles as one mosaic) can be the imagery; no tile server is involved. mapcv reads it directly, keeps its CRS, pixel grid, bands and data type, and reprojects the labels onto it. Patches can be written as PNG/JPEG (8-bit RGB), NPY or georeferenced GeoTIFF.

imagery:
  type: geotiff
  path: ortho/scene.tif      # or https://.../scene.tif, s3://bucket/scene.tif, or tiles/*.tif (a mosaic)
  # bands: [1, 2, 3]         # 1-based, default: all
  # overview: 0              # reduced-resolution level
  # nodata: 0                # override the file's NoData

Sentinel-2 can come from an EOPF Zarr product (type: eopf_zarr) or be found for your region and dates in a STAC catalog (type: stac_cog, with SCL cloud masking); Earth Engine images use imagery.earth_engine. Every option: configuration reference.

AI agents

pip install "mapcv[mcp]" adds mapcv mcp, an MCP server that lets Claude Code, Claude Desktop, Cursor or VS Code inspect labels, validate, plan and generate datasets. It is read-only by default, confined to one folder (--root), and refuses large jobs until you confirm them. In Claude Code, /plugin marketplace add tahamukhtar20/mapcv then /plugin install mapcv@mapcv also installs the agent skill. See Use mapcv with AI agents.

Documentation

Full documentation including configuration reference, CLI reference, and API reference is available at tahamukhtar20.github.io/mapcv.

Contributing

Contributions are welcome. Please review the Contributing Guide and Code of Conduct before opening a pull request.

Citation

If mapcv helped your work, please cite it. The DOI 10.5281/zenodo.23149438 covers every release and always resolves to the latest one:

@software{mukhtar_mapcv,
  author  = {Mukhtar, Muhammad Taha},
  title   = {mapcv: computer-vision datasets from map imagery and geospatial labels},
  year    = {2026},
  doi     = {10.5281/zenodo.23149438},
  url     = {https://github.com/tahamukhtar20/mapcv},
  license = {MIT}
}

GitHub's "Cite this repository" button gives the same from CITATION.cff. See Citing mapcv for the DOI of a single version and for crediting the data sources.

Author

Muhammad Taha Mukhtar · tahamukhtar20+mapcv@gmail.com

License

This project is licensed under the MIT License — see the LICENSE file for details.

Metadata

Release files for mapcv 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mapcv 0.3.1
File Size Uploaded Provenance Actions
mapcv-0.3.1.tar.gz 1.1 MB With provenance Details for mapcv-0.3.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for mapcv 0.3.1
File Actions
mapcv-0.3.1-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for mapcv-0.3.1-cp310-abi3-win_amd64.whl
mapcv-0.3.1-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details for mapcv-0.3.1-cp310-abi3-musllinux_1_2_x86_64.whl
mapcv-0.3.1-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details for mapcv-0.3.1-cp310-abi3-musllinux_1_2_aarch64.whl
mapcv-0.3.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for mapcv-0.3.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
mapcv-0.3.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for mapcv-0.3.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
mapcv-0.3.1-cp310-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64, macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64 Details for mapcv-0.3.1-cp310-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl

Total release size: 24.4 MB

Release files / mapcv-0.3.1.tar.gz

Download URL mapcv-0.3.1.tar.gz
Size 1.1 MB
Tags Source
SHA-256 checksum
How to use checksums
ba13e7c2b596466dc2cf89d996ee6675a17a27838478684789d8bd930bbe0bc6
BLAKE2b-256 checksum
How to use checksums
c7adb0da3791c7cc099a3e8035e310218a9dadccdee8739ad5a25b467509b705
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Release files / mapcv-0.3.1-cp310-abi3-win_amd64.whl

Download URL mapcv-0.3.1-cp310-abi3-win_amd64.whl
Size 3.2 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
584173cb1da3bf1513fe488e310f8ecf83333e48b88efb4a7e3ebb928f7fbb3f
BLAKE2b-256 checksum
How to use checksums
8a8f38995698cb0cac3906ce274ab3f2cbe62d1d3b3e605f312e05855061db32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Release files / mapcv-0.3.1-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL mapcv-0.3.1-cp310-abi3-musllinux_1_2_x86_64.whl
Size 3.7 MB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
d6bcd698f34a3938ce58b7dcf97d4eaa309c60aa8fe86f7b0df4a5f90821c16b
BLAKE2b-256 checksum
How to use checksums
411375456cbe2bab5903de739533ad57dfe1d26ad48669fdc4033a184453a9f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Release files / mapcv-0.3.1-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL mapcv-0.3.1-cp310-abi3-musllinux_1_2_aarch64.whl
Size 3.4 MB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
91ede00599cc6dcbc1c828a075ceb55141e4605332dd34769a334a70cce77233
BLAKE2b-256 checksum
How to use checksums
caaa3c0c6ee84db35b9cace61fd1a2dfbb7e79fc9a99427c1c035e9c05048ba8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Release files / mapcv-0.3.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL mapcv-0.3.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 3.5 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
8646ab61b9ac003a0921731576b4e6158750256d1394f40aa39432456defafe4
BLAKE2b-256 checksum
How to use checksums
1db1c4d998e7630ab90985c32964353403c9ef757b49d26569726be282cb693c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Release files / mapcv-0.3.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL mapcv-0.3.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 3.2 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
b39f18daeca4d66a6b1989f2c01e4b12dfa34ed977550c6fddaa578969675ad9
BLAKE2b-256 checksum
How to use checksums
cd04060a86ceea77621d503cd6d8f69072c975ed8b33b4bcd19fa0e4497e8fa3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Release files / mapcv-0.3.1-cp310-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl

Download URL mapcv-0.3.1-cp310-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl
Size 6.2 MB
Tags CPython 3.10 abi3 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
818d9973e1ab10faae0bd630781909ab77352b5dcab176602144458dc7f9645c
BLAKE2b-256 checksum
How to use checksums
0e01465e9ac923902f63f5d463458ca1a72ced84cb5c7521fb21178799fd4443
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Security for mapcv 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 7 files in this release have been uploaded with provenance metadata.

Select from 7 files

Attestation for mapcv-0.3.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page