go.Contour on top of px.xxxx_mapbox

Hello,

I’m currently trying to work with weather sensors data (shape of data: <lon, lat, value, sensor_name, timestamp>). I’d like to use go.Contour to interpolate between the different data points and plot that on top of a scatter_mapbox where I have a point for each sensor (using sensor_name). But currently, the Contour object seems to flash when loading and then disappear when the map is loaded. When moving on the map, while loading, the Contour seems to appear on the background, doesn’t seem to share the same x, y axis as the mapbox. I.e. there’s no rescaling of the Contour.

So my questions are: is there a way to plot a Contour on top of a Mapbox ? Alternatively, is it possible to export the Contour to GeoJSON that could be loaded for example in a choropleth_mapbox as having 2 mapbox on top of each other work flawlessly? Do you have any other idea ?

PS: I tried to use scipy.griddata to generate the values between the data points and then using choropleth_mapbox, but it’s pretty slow when loading.

Hi @tvaucher,

At the moment you cannot draw a Contour above a go.Scattermapbox, but you can define a go.Densitymapbox
https://plotly.com/python/mapbox-density-heatmaps/, which is a kind of heatmap on a mapbox map.

Hello @empet ,
Thanks for your reply. I’m aware of Densitymapbox (actually made a PR to fix a bug with the opacity). But it sadly doesn’t fit the bill. My data is pretty sparse (say 25 datapoints for a city the size of Zürich) and I’m not interested in knowing how many points there are in a zone, but rather interpolate between my points to get a surface.
So as my first idea is out of the window, is there a way to extract the Contour shapes from go.Contour. As I’m not familiar with the internals of graph_obj. I tried .data but to no avail.

@tvaucher You can plot only contour lines, by interpolating your data to get closed curves or just lines, in lon and lat coordinates, and then define mapbox_layers, as I did herehttps://community.plotly.com/t/circle-on-scattermapbox-with-coordinates-as-reference/36633/2 for such a closed curve.