I would like to create a plotly map with different gps positions.
And then I would like to overlay a wind rose/polar chart or an arrow for speed and wind direction on the map for each gps position.
I tried this but it’s not working:
import pandas as pd
import plotly.graph_objects as go
import plotly.express as px
# Define windrose data
wind_data = px.data.wind()
# Define locations
locations = {
"Vienna": (48.2082, 16.3738),
"Salzburg": (47.8095, 13.055),
"Innsbruck": (47.2692, 11.4041),
"Graz": (47.0707, 15.4395),
"Linz": (48.3064, 14.2936)
}
# Create a DataFrame from the locations dictionary
df_locations = pd.DataFrame(locations.values(), index=locations.keys(), columns=['lat', 'lon'])
# Create a map figure
fig_map = px.scatter_mapbox(df_locations, lat="lat", lon="lon", zoom=7,
mapbox_style="carto-positron")
# Define windrose trace
fig_windrose = px.bar_polar(wind_data, r="frequency", theta="direction",
color="strength", template="plotly_dark",
color_discrete_sequence=px.colors.sequential.Plasma_r)
# Add windrose trace to the map
fig_map.add_trace(go.Barpolar(
r=fig_windrose.data[0]['r'],
theta=fig_windrose.data[0]['theta'],
width=fig_windrose.data[0]['width'],
marker=dict(color=fig_windrose.data[0]['marker']['color']),
name='Windrose',
thetaunit='degrees',
))
# Update map layout
fig_map.update_layout(
mapbox=dict(
center=dict(lon=13, lat=47),
style="carto-positron",
zoom=4,
),
showlegend=False,
)
# Show the figure
fig_map.show()
Do any of you have an idea how to do this in Plotly? Thank you very much.