上下文底图是空白的,带有点 GeoDataFrame

问题描述

我有一个带有纬度/经度的单个地址的数据框,我将其转换为 GeoPandas 数据框。我将投影设置为 Contextily 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,通过更改源和缩放级别,但没有解决

解决方法

几何图形的 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)