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

feat: add France's regions to country map visualization #25676

Merged
merged 2 commits into from
Oct 19, 2023
Merged

feat: add France's regions to country map visualization #25676

merged 2 commits into from
Oct 19, 2023

Conversation

dmeaux
Copy link
Contributor

@dmeaux dmeaux commented Oct 17, 2023

SUMMARY

France's Regions have been added as a selection to the Country Map visualization. The geometries were taken from IGN's (France's National Geographic Institute) BD TOPO (R) administrative layer, and the ISO 3166-02 codes for the regions were added as an attribute.

BEFORE/AFTER SCREENSHOTS

France's Departments:
france_departments

France's Regions:
france_regions

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue: feat: add France's regions to country map visualization #25673
  • 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

@dmeaux dmeaux changed the title feat: add France's regions to country map visualization (#25673) feat: add France's regions to country map visualization Oct 17, 2023
Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for adding the regional granularity!

@rusackas rusackas merged commit ee23690 into apache:master Oct 19, 2023
26 checks passed
@qleroy
Copy link
Contributor

qleroy commented Jan 29, 2024

@dmeaux Does it work on your system ?

The file france_regions.geojson appear to be huge compared to the other ones (12 MB).

It does not display correctly

france regions broken

But it can confirm it displays correctly with matplotlib, using the Country Map GEOJSON Generator notebook.

What could be the problem ?

@dmeaux
Copy link
Contributor Author

dmeaux commented Jan 29, 2024 via email

@qleroy
Copy link
Contributor

qleroy commented Jan 29, 2024

@dmeaux

I think the geojson file expects latitude (range -90 to +90) and longitude (-180 to +180) values,

but the coordinates in france_regions.json are in the range 1e+6.

excerpt

{ "type": "Feature", "...n", "coordinates": [ [ [ [ 654467.0, 6522631.600000000558794 ], [ 654463.90...
Screenshot 2024-01-29 at 10 38 05

@dmeaux
Copy link
Contributor Author

dmeaux commented Jan 29, 2024

@qleroy
Yeah, usually geojson is in WGS84 with longitude and latitude as the X/Y coordinates, but you can embed projected data as well.

Check out this line at the top of the file:
`"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::2154" } }
This refers to the Coordinate Reference System, which in this case is EPSG:2154, or Lambert 93.

I will reproject the data to WGS 84 and simplify the geometries to decrease the file size and then recommit the file. This should fix the issues you're seeing.

@qleroy
Copy link
Contributor

qleroy commented Jan 29, 2024

thank you @dmeaux

maybe d3 does not take the coordinates system into account I don't know.

I was considering including also DOM/TOM with cartiflette
https://observablehq.com/@linogaliana/cartiflette-demo?collection=@linogaliana/cartiflette

@qleroy
Copy link
Contributor

qleroy commented Jan 29, 2024

I double checked,
indeed france_regions.geojson is the only file exceeding the bounds

According to d3 docs and referring to the plugin CountryMap.js, all *.geojson files are expected to be projected with the default projection.

All geojson files are in the urn:ogc:def:crs:OGC:1.3:CRS84 projection except for france_regions.geojson !

So that is why it cannot by displayed properly in Superset with the plugin code as is.

for f in $(ls superset/superset-frontend/plugins/legacy-chart-country-map/src/countries)
do
echo $f
jq '.crs' $f
done
france_regions.json urn:ogc:def:crs:OGC:1.3:CRS84

{
  "type": "name",
  "properties": {
    "name": "urn:ogc:def:crs:EPSG::2154"
  }
}

...

france.geojson
{
  "type": "name",
  "properties": {
    "name": "urn:ogc:def:crs:OGC:1.3:CRS84"
  }
}
...
import geopandas as gpd

df = gpd.read_file('superset-frontend/plugins/legacy-chart-country-map/src/countries/france_regions.geojson')
print(df.bounds)

france_regionsgeojson
         minx       miny       maxx       maxy
0    428145.7  6137101.2   848021.3  6439668.0
1    476864.7  6584220.1   709599.9  6872271.0
2    342953.8  6788980.8   612865.2  6998209.9
3    311617.1  6193024.1   669901.0  6679340.2
4    728354.5  6710828.6  1082838.3  7009414.0
5    799585.9  6214487.5  1077719.3  6453457.6
6    626126.3  6338318.9  1027292.6  6633794.6
7    688333.0  6562601.2  1011638.9  6811153.5
8    276123.7  6582709.1   545050.0  6834664.4
9    583916.5  6859783.5   790288.4  7110478.8
10    99040.0  6704161.1   400665.5  6886001.0
11  1156227.0  6046546.3  1242440.3  6235448.1
12   586421.7  6780020.5   741205.6  6905411.1

@dmeaux
Copy link
Contributor Author

dmeaux commented Jan 29, 2024

I've created a pull request with the updated geojson file. Until it gets merged you can use the new GeoJSON file.

france_regions_geojson

@xavier-GitHub76
Copy link
Contributor

Hello,

I use superset 3.1.1 but I have the same issue :
image

Best resgards

@xavier-GitHub76
Copy link
Contributor

It's OK with 4.0.2 version 👍

image

vinothkumar66 pushed a commit to vinothkumar66/superset that referenced this pull request Nov 11, 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/S 🚢 3.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants