I am new to geopandas and would like to plot only the outline of a polygon, similar to the function ST_Boundary()
in PostGIS
I have a geodataframe states
containing polygons for each state
states = counties.dissolve(by='STATEFP')
When I subset by one state, I am able to plot that state:
states.loc[states.index.isin(['06'])]['geometry']
I am only interested in the outline but it is not clear in the documentation how to convert a polygon to line geometry however. Is there a useful method in geopandas
or another spatial library that might help in converting a polygon to a linestring?
You can get boundary as
states.boundary
Alternatively, if you want only exterior boundary you get it as
states.exterior
Those give you new GeoSeries
with line geometry.