与点地理数据框相关的底图为空

2024-09-30 16:28:42 发布

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

我有一个带有lat/long的单个地址的数据帧,我将其转换为GeoPandas数据帧。我将投影设置为上下文EPSG:3857投影

df = gpd.GeoDataFrame(df_vf, geometry=gpd.points_from_xy(df_vf.longitude,df_vf.latitude), crs='EPSG:3857')
df
    file_state  geometry
4588464 GA  POINT (-84.20550 33.96780)
4668958 GA  POINT (-81.21680 32.29210)
6530022 GA  POINT (-84.98100 34.88710)
1936043 GA  POINT (-84.42160 34.03330)
5649637 GA  POINT (-83.83120 32.62850)

所有这些人都在乔治亚州,所以我认为这些观点是正确的。我用df.crs确认EPSG是3857。我正在尝试使用以下方法在一个上下文绘图上绘制点:

ax = df.plot(figsize=(10,10), alpha=0.5, edgecolor='k')
cx.add_basemap(ax, crs=df.crs.to_string(), zoom = 10)

Here is the resulting blank plot

我试图听从其他有类似问题的人的建议:Github issueStack Overflow issue通过更改源和缩放级别,但这并没有解决问题


Tags: 数据dfplotissueaxepsglongpoint
1条回答
网友
1楼 · 发布于 2024-09-30 16:28:42

几何图形的CRS不是3857,而是4326。坐标以度为单位

df = gpd.GeoDataFrame(df_vf, 
                      geometry=gpd.points_from_xy(df_vf.longitude,df_vf.latitude), 
                      crs='EPSG:4326')

ax = df.plot(figsize=(10,10), alpha=0.5, edgecolor='k')
cx.add_basemap(ax, crs=df.crs, zoom = 10)

相关问题 更多 >