Choropleth map not working with my geojson data

Any idea why my choropleth plot is not working out? It just shows one of the 11 areas and colors the rest of the map in one solid color. You can see it on chart studio here: https://chart-studio.plotly.com/~mbkupfer/81/#/plot

I’m not doing anything out of the ordinary. Here is the code I’m using to create the plot:

fig = px.choropleth(
    ni_df,
    geojson=ni_geojson,
    color='ind',
    locations='code',
    featureidkey='properties.LGDCode',
    projection='mercator',
    hover_data=['name']
)
fig.update_geos(fitbounds="locations", visible=False)
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})

Plotting the geojson file in geojson.io shows that is a valid format:

So it appear this is NOT plotly related, rather it had to do with the json compressor I’m using, https://mapshaper.org/. I normally never had a problem with this tool so I never thought to test it out!
When I tried plotting with the uncompressed geojson the map came out fine, despite taking ages to load… :grimacing:

Any geojson nerds in the house? Would love to figure out how I can properly compress this data. This is also an issue with the other UK geojson data sets that I got from the same source, I just decided to debug w/Northern Ireland since it was the smalled. Is there an issue with that dataset? The geojson I used for Northern Ireland can be found here: https://github.com/martinjc/UK-GeoJSON/blob/master/json/administrative/ni/lgd.json

1 Like

So I found out that the problem was related to an incompatibility between d3 and the current revision of the GeoJSON standard.

I know it has just been me talking to myself here, but for future readers who also run into this issue, the solution, and this is assuming you are using mapshaper, is to add the gj2008 flag to the -o command so that mapshaper will output clockwise rings. Reference: https://github.com/mbloch/mapshaper/issues/432#issuecomment-675775465

1 Like

Yay, thanks so much, you solved my problem too! Kudos!

1 Like

@mbkupfer You are a lifesaver. Thanks for posting the solution even though no one answered at the time.