Skip to content

fix(country-map): Madagascar's boundaries should have unique ISO - #42471

Open
lf-novelt wants to merge 16 commits into
apache:masterfrom
lf-novelt:lf/mdg-boundaries-update-master
Open

fix(country-map): Madagascar's boundaries should have unique ISO#42471
lf-novelt wants to merge 16 commits into
apache:masterfrom
lf-novelt:lf/mdg-boundaries-update-master

Conversation

@lf-novelt

@lf-novelt lf-novelt commented Jul 27, 2026

Copy link
Copy Markdown

Resolve #41883

SUMMARY

  • add geojson override for Madagascar's admin1 borders using official W.H.O. AFRO boundaries arcgis server instead of outdated data from NaturalEarth (⚠️admin1 ISO codes are different from before, because there are unique now!)
  • refresh all other boundaries from the script (no source change, but i can exclude from PR if needed)

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before

Same values / colors for multiple regions having the same ISO code.
image

20260727-1033-10 2760223

After

Unique ISO values for regions
image
image

  • Jupyter notebook preview
image

TESTING INSTRUCTIONS

Add a chart with Country Map > Madagascar.
Observe that regions now have unique ids. and values are not merged together anymore

ADDITIONAL INFORMATION

  • Has associated issue: Fixes [Country map] Madagascar ISO_3166-2 admin1 boundaries are not unique #41883
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

NoteBook python block


# Source: W.H.O. AFRO GDB Public Data
# Licence: CC BY-NC-SA 3.0 IGO

mdg_url = (
    "https://maps.afro.who.int/server/rest/services/Hosted/AFROGDB_PUBLIC_DATA/"
    "FeatureServer/0/query?where=iso3_code+%3D+%27MDG%27+and+boundary_type_id+%3D+1"
    "&geometryType=esriGeometryEnvelope&defaultSR=&spatialRel=esriSpatialRelIntersects"
    "&units=esriSRUnit_Foot&outFields=level_id%2Cdisplay_name&returnGeometry=true&f=geojson"
)

mdg_gdf = gpd.read_file(mdg_url)  # already in EPSG:4326

# Simplify directly in EPSG:4326 -> degrees conversion for Madagascar for ~50m resolution but had to adapt factor for the target size of the file to be roughly same than other ie 200KB
MEAN_METERS_PER_DEGREE_MDG = 108_000
tolerance_deg = 10 * 50 / MEAN_METERS_PER_DEGREE_MDG

mdg_gdf["geometry"] = mdg_gdf.geometry.simplify(tolerance=tolerance_deg, preserve_topology=True)

# reverse the point order of the exterior ring(s) (cf https://ruky.me/how-to-correctly-load-your-country-in-to-apache-superset/#step-5--converting-geojson-file-to-go-against-right-hand-rule)
mdg_gdf["geometry"] = mdg_gdf.geometry.apply(
    lambda geom: Polygon(list(geom.exterior.coords)[::-1])
    if geom.geom_type == "Polygon"
    else MultiPolygon([Polygon(list(poly.exterior.coords)[::-1]) for poly in geom.geoms])
)


madagascar_copy = mdg_gdf.copy().rename(columns={'level_id': 'iso_3166_2', 'display_name': 'name'})
  • additional references of madagascar_copy in the shared block

@dosubot dosubot Bot added change:frontend Requires changing the frontend viz:charts:map Related to Map charts labels Jul 27, 2026
@netlify

netlify Bot commented Jul 27, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 7b43760
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a883080f5dd7e00093a567d
😎 Deploy Preview https://deploy-preview-42471--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@bito-code-review

Copy link
Copy Markdown
Contributor

Bito Review Skipped - No Changes Detected

Bito didn't review this pull request because we did not detect any changes in the pull request to review.

@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.84%. Comparing base (65910ab) to head (7b43760).
⚠️ Report is 283 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #42471   +/-   ##
=======================================
  Coverage   66.84%   66.84%           
=======================================
  Files        2876     2876           
  Lines      164069   164069           
  Branches    37866    37866           
=======================================
  Hits       109666   109666           
  Misses      52228    52228           
  Partials     2175     2175           
Flag Coverage Δ
javascript 74.12% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lf-novelt lf-novelt changed the title fix(dashboard): MDG boundaries unique ISO fix fix(charts): MDG boundaries unique ISO fix Jul 27, 2026
@lf-novelt lf-novelt changed the title fix(charts): MDG boundaries unique ISO fix fix(charts): MDG boundaries should have unique ISO Jul 27, 2026
@lf-novelt
lf-novelt force-pushed the lf/mdg-boundaries-update-master branch from ed2cd6c to 3254073 Compare July 27, 2026 14:47
@lf-novelt lf-novelt changed the title fix(charts): MDG boundaries should have unique ISO fix(chart): MDG boundaries should have unique ISO Jul 27, 2026
@lf-novelt lf-novelt changed the title fix(chart): MDG boundaries should have unique ISO fix(chart): Madagascar's boundaries should have unique ISO Jul 27, 2026
@lf-novelt lf-novelt changed the title fix(chart): Madagascar's boundaries should have unique ISO fix(chart): [Country map] Madagascar's boundaries should have unique ISO Jul 27, 2026
@lf-novelt lf-novelt changed the title fix(chart): [Country map] Madagascar's boundaries should have unique ISO fix(country-map) Madagascar's boundaries should have unique ISO Jul 28, 2026
@lf-novelt

lf-novelt commented Jul 28, 2026

Copy link
Copy Markdown
Author

@jpmonette i've merged latest from master, but not sure your fix #29503 was correctly included, how can i check?

does the plot look ok? else can you highlight the section you changed in the notebook?
image

@rusackas rusackas changed the title fix(country-map) Madagascar's boundaries should have unique ISO fix(country-map): Madagascar's boundaries should have unique ISO Jul 28, 2026
@rusackas
rusackas requested a review from Copilot July 28, 2026 20:52
@rusackas

Copy link
Copy Markdown
Member

Lookin' good to me thus far... running Copilot to see if it catches anything I didn't spot myself.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request updates the legacy Country Map plugin’s built-in GeoJSON boundary data to resolve Madagascar admin1 identifier collisions (so regions map to unique IDs), and refreshes some other country boundary metadata produced by the generator.

Changes:

  • Replace Madagascar admin1 boundaries with WHO AFRO-sourced regions and unique per-region identifiers.
  • Update the Country Map GeoJSON generator notebook with a Madagascar-specific data source and processing steps.
  • Refresh other shipped GeoJSONs (example shown: Morocco NAME_1 label corrections/diacritics).

Reviewed changes

Copilot reviewed 1 out of 4 changed files in this pull request and generated 2 comments.

File Description
superset-frontend/plugins/legacy-plugin-chart-country-map/src/countries/madagascar.geojson Updates Madagascar admin1 features to use 23 regions with unique IDs (new properties.ISO values).
superset-frontend/plugins/legacy-plugin-chart-country-map/scripts/Country Map GeoJSON Generator.ipynb Adds/updates Madagascar generation logic using WHO AFRO ArcGIS FeatureServer and post-processing.
superset-frontend/plugins/legacy-plugin-chart-country-map/src/countries/morocco.geojson Refreshes region display names (e.g., diacritics/correct spellings) consistent with regenerated data.

@github-actions github-actions Bot added the doc Namespace | Anything related to documentation label Aug 19, 2026
@bito-code-review

bito-code-review Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #142cf9

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 084ff8c..d2dd61f
    • docs/admin_docs/configuration/country-map-tools.mdx
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@rusackas

Copy link
Copy Markdown
Member

Not sure why Kenya is showing as modified here... maybe the map data was updated upstream, and your-re-run of the notebook just "updated" it as bycatch?

@rusackas

Copy link
Copy Markdown
Member

Really nice work here, @lf-novelt, especially the ISO caveat you added to the docs.

One thing before I approve, though: the Madagascar cell doesn't cite a license the way the Kenya cell does. Could you add a note on what license the WHO AFRO GeoPortal data (maps.afro.who.int) is under? WHO's general data terms default to CC BY 4.0, but that's data.who.int, and I'm not sure it covers the AFRO Geodatabase too.

Happy to approve once that's sorted!

@lf-novelt

lf-novelt commented Aug 20, 2026

Copy link
Copy Markdown
Author

thanks for the feedback, i will confirm with WHO AFRO about the license used there, but it should be someting like "Licence: CC BY-NC-SA 3.0 IGO" that they use in most if their publications. Will update the notebook and refresh Kenya as well.

EDIT: i've added the license as coment and re-run the whole notebook and pushed all updated countries as well with latest boundaries from their respective source

@github-actions github-actions Bot added the requires:rebase Requires rebasing on top of current master label Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:frontend Requires changing the frontend doc Namespace | Anything related to documentation plugins requires:rebase Requires rebasing on top of current master size/XXL viz:charts:map Related to Map charts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Country map] Madagascar ISO_3166-2 admin1 boundaries are not unique

3 participants