Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

Geojson data in scatter_geo only draws points, not areas

Hi,
I would like to use the scatter_geo chart and place some geojson shapes on it. It looks like it only picks points, not the entire shapes, no matter what I do :). I tried tracing how the locationmode='geojson-id' parameter is used, looks like its only passed to plotly.js, so not sure how to tag it here properly, since I was using plotly.py.
Maybe I didnt get it right and am not using it properly ?
example:
it can also be seen on deepnote

data definition

features_geo = [
    geojson.Feature(
    id=1,
    geometry=geojson.Polygon([[(1,1),(20,1),(20,20),(1,20),(1,1)]]),
    properties={'name':'a'}
    ),
    geojson.Feature(
    id=2,
    geometry=geojson.Polygon([[(30,30),(40,30),(40,40),(30,40),(30,30)]]),
    properties={'name':'b'}
    ),
    geojson.Feature(
    id=3,
    geometry=geojson.Polygon([[(-1,1),(-20,1),(-20,20),(-1,20),(-1,1)]]),
    properties={'name':'c'}
    ),
    geojson.Feature(
    id=4,
    geometry=geojson.Polygon([[(-30,30),(-40,30),(-40,40),(-30,40),(-30,30)]]),
    properties={'name':'d'}
    ),
]
collection = geojson.FeatureCollection(features_geo)
feature_data = pd.DataFrame([
    {'id':1,'val':1,'name':'a'}, 
    {'id':3,'val':3, 'name': 'c'},
    {'id':4,'val':4, 'name': 'd'},
    {'id':2,'val':2, 'name': 'b'},
])

Drawing the chart

fig = px.scatter_geo(
    data_frame=feature_data,
    geojson=collection,
    locations='id',
    locationmode='geojson-id',
    projection='orthographic',
    color='val'
)
fig.update_traces(patch={'fill':"toself"})
fig

This is what I get:

  • it takes 1 point from each polygon and connects them, instead of painting the polygons

thanks :slight_smile: