如何使用plotly python和卫星视图从pandas数据框标记点(使用纬度和经度)

2024-10-01 00:20:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我想用plotly python和satellite view从熊猫数据框中标记点(使用纬度和经度)。 样本df:

    device  GPSTime     GPSLat       GPSLng
    101    1614956574   16.94469    29.8267
    102    1615271467   16.94503    29.83
    103    1615271488   16.94553    29.83

我使用Plotly绘制数据,但没有获得卫星视图。有没有办法得到卫星图像

霉菌代码:

import plotly.express as px 
fig = px.scatter_mapbox(dfL, lat="GPSLat", lon="GPSLng", zoom=15, height=500,width=1000,color="device")
fig.update_layout(mapbox_style="open-street-map") 
fig.show()

当前视图: enter image description here

但我需要在satalite图像上绘制这些数据?有没有办法得到卫星图像


Tags: 数据标记图像view视图devicefig绘制
1条回答
网友
1楼 · 发布于 2024-10-01 00:20:09

首先,如果要使用mapbox,需要获取mapbox的APIKey。获得APIKey后,可以使用以下代码以指定的样式绘制卫星图像

import plotly.express as px

px.set_mapbox_access_token(open("mapbox_api_key.txt").read())
fig = px.scatter_mapbox(df,
                        lat=df.GPSLat,
                        lon=df.GPSLng,
                        hover_name="device",
                        height=500, width=1000,
                        zoom=15, mapbox_style='satellite')

fig.show()

enter image description here

相关问题 更多 >