Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(maps): france_regions.geojson generated with the notebook, from natural earth data #27014

Merged
merged 6 commits into from
Feb 6, 2024

Conversation

qleroy
Copy link
Contributor

@qleroy qleroy commented Feb 5, 2024

Following #26995, and to fix the countries_custom/france_regions.geojson added in #25676,
I propose to generate france_regions.geojson from the data provided department-wise by Natural Earth Data
but that can be merged together into their parent division, i.e. regions.
The geopandas dissolve function can do just that and the mapping departments=>regions comes from the ISO 3166-2 FR norm

SUMMARY

The previous france_regions.geojson ,while it was generated from a solid source (IGN BD TOPO), is large (12MB) compared to other files and provided in the incorrect projection (EPSG 2154 instead of EPSG 4326 / WGS 84), resulting in a buggy display in Superset while using the Country Map plugin.

All files from Natural Earth Data are provided with the EPSG 4326 / WSG 84 (source) and it is the projection understood by the Country Map plugin as its current implementation.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

In the notebook
notebook

In Superset
superset

Most relevant bit of code in the notebook:

france_regions = france_copy.copy()
# Define the mapping from the departments to their parent division
# i.e. from departments to regions
# Source: https://www.iso.org/obp/ui/#iso:code:3166:FR
dep_to_reg = {
    "FR-01": "FR-ARA",
    "FR-02": "FR-HDF",
    "FR-03": "FR-ARA",
    "FR-04": "FR-PAC",
    "FR-05": "FR-PAC",
    "FR-06": "FR-PAC",
    "FR-07": "FR-ARA",
    "FR-08": "FR-GES",
    "FR-09": "FR-OCC",
    "FR-10": "FR-GES",
    "FR-11": "FR-OCC",
    "FR-12": "FR-OCC",
    "FR-13": "FR-PAC",
    "FR-14": "FR-NOR",
    "FR-15": "FR-ARA",
    "FR-16": "FR-NAQ",
    "FR-17": "FR-NAQ",
    "FR-18": "FR-CVL",
    "FR-19": "FR-NAQ",
    "FR-21": "FR-BFC",
    "FR-22": "FR-BRE",
    "FR-23": "FR-NAQ",
    "FR-24": "FR-NAQ",
    "FR-25": "FR-BFC",
    "FR-26": "FR-ARA",
    "FR-27": "FR-NOR",
    "FR-28": "FR-CVL",
    "FR-29": "FR-BRE",
    "FR-2A": "FR-20R",
    "FR-2B": "FR-20R",
    "FR-30": "FR-OCC",
    "FR-31": "FR-OCC",
    "FR-32": "FR-OCC",
    "FR-33": "FR-NAQ",
    "FR-34": "FR-OCC",
    "FR-35": "FR-BRE",
    "FR-36": "FR-CVL",
    "FR-37": "FR-CVL",
    "FR-38": "FR-ARA",
    "FR-39": "FR-BFC",
    "FR-40": "FR-NAQ",
    "FR-41": "FR-CVL",
    "FR-42": "FR-ARA",
    "FR-43": "FR-ARA",
    "FR-44": "FR-PDL",
    "FR-45": "FR-CVL",
    "FR-46": "FR-OCC",
    "FR-47": "FR-NAQ",
    "FR-48": "FR-OCC",
    "FR-49": "FR-PDL",
    "FR-50": "FR-NOR",
    "FR-51": "FR-GES",
    "FR-52": "FR-GES",
    "FR-53": "FR-PDL",
    "FR-54": "FR-GES",
    "FR-55": "FR-GES",
    "FR-56": "FR-BRE",
    "FR-57": "FR-GES",
    "FR-58": "FR-BFC",
    "FR-59": "FR-HDF",
    "FR-60": "FR-HDF",
    "FR-61": "FR-NOR",
    "FR-62": "FR-HDF",
    "FR-63": "FR-ARA",
    "FR-64": "FR-NAQ",
    "FR-65": "FR-OCC",
    "FR-66": "FR-OCC",
    "FR-67": "FR-GES",
    "FR-68": "FR-GES",
    "FR-69": "FR-ARA",
    "FR-70": "FR-BFC",
    "FR-71": "FR-BFC",
    "FR-72": "FR-PDL",
    "FR-73": "FR-ARA",
    "FR-74": "FR-ARA",
    "FR-75": "FR-IDF",
    "FR-76": "FR-NOR",
    "FR-77": "FR-IDF",
    "FR-78": "FR-IDF",
    "FR-79": "FR-NAQ",
    "FR-80": "FR-HDF",
    "FR-81": "FR-OCC",
    "FR-82": "FR-OCC",
    "FR-83": "FR-PAC",
    "FR-84": "FR-PAC",
    "FR-85": "FR-PDL",
    "FR-86": "FR-NAQ",
    "FR-87": "FR-NAQ",
    "FR-88": "FR-GES",
    "FR-89": "FR-BFC",
    "FR-90": "FR-BFC",
    "FR-91": "FR-IDF",
    "FR-92": "FR-IDF",
    "FR-93": "FR-IDF",
    "FR-94": "FR-IDF",
    "FR-95": "FR-IDF",
    "FR-GF": "FR-GF",
    "FR-MQ": "FR-MQ",
    "FR-GP": "FR-GP",
    "FR-RE": "FR-RE",
    "FR-YT": "FR-YT",
}
# Apply the mapping departments => regions
france_regions["iso_3166_2_region"] = france_regions['iso_3166_2'].apply(lambda x: dep_to_reg[x])
# Merge the departments together 
# https://geopandas.org/en/stable/docs/user_guide/aggregation_with_dissolve.html
france_regions = france_regions.dissolve(by='iso_3166_2_region')
# Fix the label
france_regions['iso_3166_2'] = france_regions['iso_3166_2'].index
# Fix the name
france_regions['name'] = france_regions['region']
france_regions.plot()

TESTING INSTRUCTIONS

Run the notebook to generate the new france_regions.geojson

ADDITIONAL INFORMATION

Copy link
Member

@rusackas rusackas left a comment

Choose a reason for hiding this comment

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

Looks good to me! Tested it in the notebook, and all seems well.

I have another PR with a notebook change... i hope these things can be merged together like any other code 😅

@rusackas rusackas merged commit 42b7bd5 into apache:master Feb 6, 2024
30 of 31 checks passed
sfirke pushed a commit to sfirke/superset that referenced this pull request Mar 22, 2024
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 4.0.0 labels Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/L 🚢 4.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants