Plotly choropleth doesn't show the map from geojson

I follow the example shown here, which uses geopandas data frame as the input to geojson parameter. I can re-produce the example.

However, when I use my own geojson data from https://geo.datav.aliyun.com/areas_v3/bound/110000_full.json, px.choropleth gives a white blank figure. The map is not shown.

The whole code is as follows:

import plotly.express as px
import geopandas as gpd

geo_df = gpd.read_file("https://geo.datav.aliyun.com/areas_v3/bound/110000_full.json")
fig = px.choropleth(geo_df,
                   geojson=geo_df.geometry,
                   locations=geo_df.name, # Change to `geo_df.index`, then it works.
                   color="subFeatureIndex",
                   projection="mercator")
fig.update_geos(fitbounds="locations", visible=False)
fig.show()

Am I missing anything when using px.choropleth with geojson data?


Well, finally I find the problem. As for the geopandas data frame as the geojson input, locations should be set to geo_df.index, then map is displayed correctly.

1 Like

I am experiencing the same problem, the map doesn’t load at all. The only thing displayed is a black space/box.