mirror of
https://github.com/apache/superset.git
synced 2026-05-29 11:45:16 +00:00
Add mapshaper -simplify as a final-stage pass after the Python transforms. Two-stage so the transforms operate on full-resolution geometry (no risk of repositioning ghost features that got simplified away) but the shipped output is browser-sized. Default 5% with keep-shapes — preserves recognizable country shapes while dropping the per-vertex bloat. keep-shapes prevents tiny features (small island chains) from being collapsed away entirely. Results on real outputs: Admin 0: 23.6 MB → 2.1 MB (-91%, 249 features intact) Admin 1: 67.7 MB → 15 MB (-78%, 4591 features, transforms preserved) Per-feature simplify factors (the notebook had a size-based ladder) can be added later if specific countries need tuning. 5% is the mapshaper-recommended "good enough for web" default. Open thought for future: split Admin 1 output by country (`<worldview>_admin1_<adm0_a3>.geo.json`) so the per-chart payload is ~50KB-1MB instead of one 15MB global file. Will pair naturally with the territory_assignments pass (which is per-country anyway). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Country Map data pipeline
This directory contains the build pipeline that turns upstream Natural Earth data into the GeoJSON files consumed by @superset-ui/plugin-chart-country-map.
It replaces the legacy scripts/Country Map GeoJSON Generator.ipynb notebook. See SIP_DRAFT.md in the parent directory for the full design rationale.
Layout
scripts/
build.sh # one-shot reproducible build
README.md # this file
config/ # declarative YAML — handles ~95% of fixes
name_overrides.yaml # typos, deprecated ISO codes, admin renames
flying_islands.yaml # repositioning + bbox drops for far-flung territories
territory_assignments.yaml # add features from sibling Admin 0 records
regional_aggregations.yaml # dissolve Admin 1 into administrative regions
composite_maps.yaml # multi-country composites (e.g. France-with-Overseas)
procedural/ # escape hatch — handles the rare 5%
README.md # when to use, when not
NN_<descriptive_name>.py # one focused script per genuine edge case
output/ # gitignored — build artifacts
Operating principles
- Default tool: declarative YAML. Most touchups are renames, repositions, dissolves, or filters — all expressible in YAML. Diffs are small, conflicts localize cleanly to one entry, contributors can submit "fix typo X" as a one-line PR.
- Escape hatch:
procedural/directory of small, named, single-purpose Python scripts for the rare cases YAML can't express cleanly. Each script has a header comment explaining why it's not in YAML. Seeprocedural/README.mdfor the bar. - Build is reproducible from a pinned NE version.
build.shrecords the NE git SHA it consumed; outputs are deterministic given inputs. - CI regenerates on schema change and opens a PR if outputs differ. Maintainers review the cartographic diff in legible GeoJSON, not opaque notebook JSON.
Workflow for adding a fix
- Identify the upstream NE issue (wrong name, missing territory, etc.).
- Try YAML first. Add the smallest possible entry to the appropriate config file with a
descriptionfield explaining the fix. - If YAML can't express it cleanly, add a numbered script in
procedural/with a header comment explaining why YAML didn't fit. - Run
build.shlocally, verify the output GeoJSON looks right. - Open PR. Reviewer sees the YAML diff (or new procedural script) plus the regenerated GeoJSON.
See also
SIP_DRAFT.md(parent dir) — design rationale, notebook audit, obsolescence checkprocedural/README.md— when to use the escape hatch