Plotting a grid or polygons over a map

I am at the moment creating a geo-grid that I would like to render using Dash and a scattermapbox. Each cell then would contains information used for side-plots and I am using some context events to show only the cells that matters.
However, with scattermapbox, it is easy to plot the center of the cell, the contour of the cells using the mode ‘lines’, but there’s no easy solution for polygons. (Q1) Do I have to pass via plotly.graph_objs and try to create some polygons out of that? If so, what would be the easiest way to integrate them? Or is there better solutions?
Looking through the web, no solutions were really satisfactory to me.

At the moment, my data comes from an SQL source, converted into a pandas dataframe of the form:

name | min Lat | max Lat | min Lon | max Lon | attribute 1 | attribute 2 | …

(Q2) Also, would such solution (if any) be much faster than plotting the contours? My grid can have easily more than 1000 cells.
Finally, my cells may, in the future, overlap. I need to think of a method allowing the user to select between them easily. (Q3) Any ideas?

Thanks a lot!

The best solution I found was using the one described in https://community.plotly.com/t/choropleth-map-in-dash/4807/2.
This is far from ideal because I have to plot the center points on top of each of the polygons and set the opacity to zero to have some some hoverinfo interactions. This means that the plot becomes twice as heavy and slow when plotting a large grid. It is yet much faster than plotting the contours and has the advantage to allow area filling.

1 Like