我最近发布了一个关于如何使用 geopandas 绘制热图的问题。我被推荐使用geoplot.kdeplot()
,但是传递了一个projection
崩溃我的会话。
df_points
假设我分别存储了以下数据df_map
:
> print(df_points)
PointID geometry
0 204403876 POINT (-101.66700 21.11670)
1 204462769 POINT (-101.66700 21.11670)
2 144407530 POINT (-101.66700 21.11670)
> print(df_map)
PolyID geometry
0 01001 POLYGON ((-102.10641 22.06035, -102.10368 22.0...
1 01002 POLYGON ((-102.05189 22.29144, -102.05121 22.2...
2 01003 POLYGON ((-102.68569 22.09963, -102.69087 22.0...
这是我尝试过的,但根据本教程,我应该将 a 传递projection
给热图。
# Import geoplot
import geoplot
import geoplot.crs as gcrs
# Plot points
ax = geoplot.kdeplot(df_points, shade=True, alpha=0.7)
# Plot polygons
geoplot.polyplot(df_map, ax=ax)
但是,如果我添加projection=gcrs.AlbersEqualArea()
,我的会话会崩溃:
# Plot heatmap
ax = geoplot.kdeplot(df_points, cmap='Reds', shade=True,
projection=gcrs.AlbersEqualArea()) # This crashes my session ):
# Add polygons
geoplot.polyplot(df_map, ax=ax)
python3: geos_ts_c.cpp:3991: int GEOSCoordSeq_getSize_r(GEOSContextHandle_t, const geos::geom::CoordinateSequence*, unsigned int*): 断言 '0 != cs' 失败。
我怎样才能通过projection=gcrs.AlbersEqualArea()
并避免错误?