Reputation: 234
Here is a sample of a dataset i got, where 'lat', and 'lon' stand for 'latitude' and 'longitude', respectively:
'lat' | 'lon' |
---|---|
25.09740093 | 55.1368825 |
25.11258035 | 55.2587537 |
25.0777321 | 55.13890908 |
25.1337145 | 55.192437 |
25.193982 | 55.2769135 |
25.0372255 | 55.216955 |
25.068809 | 55.326105 |
I tried to visualize it on map with plotly as such:
import plotly.graph_objects as go
fig = go.Figure(go.Densitymapbox(lat=df['lat'], lon=df['lon']))
fig.show()
What's wrong?
Upvotes: 0
Views: 188
Reputation: 35135
Z-value for heatmap is required as well as latitude and longitude. A reference can be found here for your reference. I specified the z-value directly in the graph code, but originally, there should be a column of z-values in the data frame, so in that case, specify the column name.
import plotly.graph_objects as go
import numpy as np
fig = go.Figure(go.Densitymapbox(lat=df.lat,
lon=df.lon,
z=np.random.randint(10,100,7),
radius=10))
fig.update_layout(
mapbox_style="stamen-terrain",
mapbox_center_lon=55.20,
mapbox_center_lat=25.11,
mapbox_zoom=9
)
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()
Upvotes: 1