How to Use Shapemaps
GeoSC donor maps use shapemap_file to read a GeoPandas-compatible vector
file and shapemap_id_column to choose the geography ID used for joins. The
values in that ID column must match the unit IDs used in your experiment data,
such as DMA IDs, postcode districts, postcode areas, or another market key.
Built wheel and sdist installs do not include the repository-local shapemap/
directory. Packaged users should provide map files from their own runtime
environment.
Basic Config
GeoSC can read formats supported by GeoPandas, including GeoJSON, TopoJSON, Shapefile, and GeoPackage inputs when the local geospatial stack supports them.
Repository-local shapemap examples are available for common markets:
shapemap/uk/postcode_areas_approx_2026.geojsonshapemap/uk/postcode_districts_approx_2026.geojsonshapemap/us/dma_legacy_normalized.geojsonshapemap/fr/nuts3_2024.geojsonshapemap/de/nuts3_2024.geojsonshapemap/<uk|us|fr|de>/meta_commuting_zones.geojson
These are source-checkout assets. They are not included in built wheel or sdist artifacts.
Meta Commuting Zones are also available as optional geographies for Meta-aligned study design. They are commuting/economic zones, not Meta ad-targeting boundaries.
UK Postcode District Example
For UK production workflows, postcode district is often the practical market geography:
The input data must use the same IDs as the shapemap:
Use scripts/prepare_uk_postcode_shapemap.py from a source checkout to
normalize licensed or user-supplied postcode polygon data:
The generated file exposes:
id: postcode district, such asSW1A,M1, orBT7name: display name, defaulting to the same value asidcountry:UKgeography_level:postcode_districtgeometry: dissolved polygon geometry
The repository includes an approximate version built from ONSPD live postcode centroids:
Validate the generated file before using it in donor evaluation:
UK Postcode Area Example
For broader UK markets, use postcode areas:
Prepare the map with:
Provenance and Licensing
Do not commit or distribute postcode geometry unless the source license permits
that use. The repository records shapemap provenance policy in
shapemap/README.md and shapemap/manifest.yaml.
For UK data:
- OS Code-Point Open is an open postcode unit point dataset, not polygon geometry.
- OS Code-Point with Polygons is the appropriate official polygon source when you have the necessary access and licensing.
- ONS Postcode Directory is useful for postcode-to-geography lookup workflows.
Troubleshooting
If donor maps do not highlight treatment or donor units:
- confirm the shapemap contains the configured
shapemap_id_column - confirm the shapemap ID values exactly match the experiment unit IDs
- normalize both sides to the same case and spacing convention
- confirm the file can be opened by
geopandas.read_file
scripts/validate_shapemap.py reports missing expected IDs, duplicate IDs,
blank IDs, null or empty geometry, invalid geometry, row counts, unique ID
counts, and the detected CRS.