project2026e / maps /README.md
cmg777's picture
Sync data/ (clean subset)
cf82112 verified
|
Raw
History Blame Contribute Delete
3.07 kB
# Municipality Boundaries (Maps)
## Overview
This directory contains the administrative boundary polygons for Bolivia's **339 municipalities**, used by the spatial/ESDA notebooks (Moran's I, LISA, choropleths).
Every feature is keyed on `asdf_id`, the universal join key used across all datasets in this project, so any tabular file in `data/` can be merged onto these geometries for mapping.
## Files
| File | Features | Properties | Description |
| ---- | -------- | ---------- | ----------- |
| `bolivia339geoqueryOpt.geojson` | 339 | `asdf_id`, `shapeName`, `COORD_X`, `COORD_Y` | **Web-optimized** boundaries (simplified geometry + centroid coordinates). Preferred for interactive maps and most analysis. |
| `bolivia339geoqueryFull.geojson` | 339 | `asdf_id` | **Full-resolution** boundaries (detailed geometry, larger file). Use when maximum geometric precision is required. |
| `archive/` | — | — | Superseded boundary versions, kept for provenance. **Local-only — not mirrored to Hugging Face.** |
## Variable Dictionary
| Property | Description |
| --- | --- |
| **asdf_id** | Unique spatial identifier (`0`–`338`) for joining to every other dataset in `data/`. |
| **shapeName** | Municipality name (present in the optimized file). |
| **COORD_X** | Municipality centroid longitude (present in the optimized file). |
| **COORD_Y** | Municipality centroid latitude (present in the optimized file). |
## Example Code
```python
import geopandas as gpd
import pandas as pd
# Load the (web-optimized) municipality boundaries
gdf = gpd.read_file("bolivia339geoqueryOpt.geojson")
# Attach any indicator and make a choropleth
sdg = pd.read_csv("../sdg/sdg.csv")
gdf = gdf.merge(sdg[["asdf_id", "index_sdg1"]], on="asdf_id")
gdf.plot(column="index_sdg1", legend=True)
```
## Access via Hugging Face
The two GeoJSON boundary files are mirrored to the public Hugging Face dataset
[`cmg777/project2026e`](https://huggingface.co/datasets/cmg777/project2026e).
(The `archive/` folder is **local-only** and is not on the Hub.)
**Browse / download in a browser:**
<https://huggingface.co/datasets/cmg777/project2026e/tree/main/maps>
**Load in Python** (pick any one):
```python
# 1) Project helper — local-first, falls back to the Hub (code/hf_data.py)
import sys, geopandas as gpd
sys.path.append("code") # add the repo-root "code" folder to the path
from hf_data import data_path
gdf = gpd.read_file(data_path("maps/bolivia339geoqueryOpt.geojson"))
# 2) Direct download from the Hub
from huggingface_hub import hf_hub_download
path = hf_hub_download("cmg777/project2026e", repo_type="dataset",
filename="maps/bolivia339geoqueryOpt.geojson")
gdf = gpd.read_file(path)
```
> The `datasets` library's `load_dataset()` targets the tabular **CSV** files in this repository;
> for GeoJSON geometry use `geopandas` with either helper above.
## Join Key
Use `asdf_id` to join these geometries with any dataset in `data/` (e.g. `sdg/sdg.csv`, `sdgVariables/sdgVariables.csv`, `satelliteEmbeddings/`, `nighttimeLights/`).