Announcing Dash Bio 1.0.0 🎉 : a one-stop-shop for bioinformatics and drug development visualizations.

Problem Of Adding Shape to Maps


I want to add a shape to my maps figure, But the result of below code is something else.

import as px

df =

fig = px.choropleth_mapbox(df, 
                           locations="district", featureidkey="properties.district",
                           center={"lat": 0.0, "lon": 0.0},
                           mapbox_style="carto-positron", zoom=2)

fig.add_shape(type="circle", xref="x", yref="y",
    fillcolor="PaleTurquoise", x0=0, y0=0, x1=0+.01, y1=0+.01,


What should I do to add a shape with the diameter that I what in the location that I want?

Such a small circle can be added with a go.Scattermapbox trace, with markers at the circle centers.
But a circle of arbitrary radius is better defined as a mapbox layer.

layers=[dict(sourcetype = 'geojson',
             source =shape,
             below=' ', 
             type = 'fill',   
             color = 'PaleTurquoise',

where shape is not defined as in the case of a trace referenced to a cartesian system but as a geojson type dict:

shape = {"type": "FeatureCollection"}
shape['features'] = [{ "type": "Feature",
                                     "geometry": {"type": "Polygon",
                                      "coordinates":  array_type }}]

where array_type is a list of lists of the form:

            [lon_1, lat_1], 
            [lon_2, lat_2],
           [lon_n, lat_n]

and (lon_k, lat_k) with k=1:n are geographical coordinates of the points on a circle with center (lon_c, lat_c).
For details on the geojson type dict see

layers definition is inserted within layout.mapbox: