So, I am using plotly mapbox plotly.express.choropleth_mapbox to display colored tiles.
Ultimately what I want to do, is to overlay a scatter plot, whether a circle, symbols, etc. Some 'Point' coordinates on top of the colored tiles.
I am not aware of a way to combine scatter_mapbox as a trace to choropleth, so I tried to update mapbox and use the circle layer, below.
Note that I've done this with an outline from another .geojson file to draw an outline on the map (yay this part works), but the overlay of circles did not work. (Also tried symbol and did not work either.)
Was trying to troubleshoot if it was my geojson file or not, since I created the file on my computer. Tried creating both in python and with QGIS.
My goal: add markers/coordinates on top of a tiled geographic map.
Here is the code below which should allow you to see the same as me.
import pandas as pd
import plotly.express as px
point_geo = {'type': 'FeatureCollection',
'name': 'locations',
'features': [{'type': 'Feature',
'properties': {'description': 'xyz', 'name': 'A'},
'geometry': {'type': 'Point', 'coordinates': [43.58283, -79.61944]}},
{'type': 'Feature',
'properties': {'description': 'xyz','name': 'B '},
'geometry': {'type': 'Point', 'coordinates': [43.58294, -79.61244]}}
]}
abc = pd.DataFrame({'FID':['19','18'],'MEDIAN INCOME':[60000,70000]})
def_= requests.get('https://opendata.arcgis.com/datasets/3a90af0bfd034a48a1bee2f7ff4f105a_0.geojson').json()
ghi_ = requests.get('https://opendata.arcgis.com/datasets/0e149347e0b54724996d99080bed1874_0.geojson').json()
fig3 = px.choropleth_mapbox(abc, geojson=def_,
featureidkey='properties.FID', locations='FID', color='MEDIAN INCOME',
mapbox_style="carto-positron",
opacity=0.4,
color_continuous_scale = px.colors.sequential.Inferno_r ,
zoom=12, center = {"lat": 43.5887 , "lon": -79.64})
fig3.update_layout(
mapbox = {
'layers': [
## this part works
{'source': ghi_,
'type': "line", 'color': "royalblue", 'opacity':1, 'line':{'width':3} },
## this part does not work
{'source':point_geo, 'type':'circle', 'circle':{'radius':2} }
]},
)
fig3.show()