Geopandas 多边形到线

isk*_*lue 7 python plot postgis spatial geopandas

我是 geopandas 新手,只想绘制多边形的轮廓,类似于ST_Boundary()PostGIS 中的功能

我有一个states包含每个州的多边形的地理数据框

states = counties.dissolve(by='STATEFP')
Run Code Online (Sandbox Code Playgroud)

当我按一个状态进行子集化时,我可以绘制该状态:

states.loc[states.index.isin(['06'])]['geometry']
Run Code Online (Sandbox Code Playgroud)

我只对轮廓感兴趣,但文档中尚不清楚如何将多边形转换为线几何形状。或另一个空间库中是否有有用的方法geopandas可以帮助将多边形转换为线串?

在此输入图像描述

mar*_*eis 7

你可以得到边界为

states.boundary
Run Code Online (Sandbox Code Playgroud)

或者,如果您只想要外部边界,您可以得到它

states.exterior
Run Code Online (Sandbox Code Playgroud)

这些给你带来新的GeoSeries线条几何形状。