I would like to add multiple layers to my plot in Mapbox using Python. Suppose, I would like to add another layer which is a scatter plot. How and where would I add it?
Also, how do I rearrange the layers so the scatter plot is above the geojson?
Thanks a lot!
Here’s my code:
data = [
go.Scattermapbox(
lat=['39.91427','38.91538','38.91458',
'39.92239','40.93222','38.90842',
'40.91931','40.93260','38.91368',
'39.88516','39.921894','38.93206',
'39.91275'],
lon=['-75.02827','-75.02013','-77.03155',
'-75.04227','-75.02854','-77.02419',
'-75.02518','-75.03304','-77.04509',
'-75.99656','-75.042438','-77.02821',
'-75.01239'],
mode='markers',
marker=go.scattermapbox.Marker(
size=9
),
)
]
layout = go.Layout(
height=600,
autosize=True,
hovermode='closest',
mapbox=dict(
layers=[ dict(
sourcetype = 'geojson',
source = 'new_export/S_FRD_Pol_Ar.json',
type = 'fill',
color = 'rgba(172, 206, 222, 1)'
),
dict(
sourcetype = 'geojson',
source = 'new_export/S_CSLF_Ar.json',
type = 'fill',
color = 'rgba(255, 237, 67, 1)'
)
],
accesstoken=mapbox_access_token,
bearing=0,
center=dict(
lat=40,
lon=-75
),
pitch=0,
zoom=10,
style='light'
),
)
fig = go.Figure(layout=layout, data=data)
iplot(fig, filename='Multiple Mapbox')