I'm new in GeoPandas and I try to create my first script.
I successfully opened a shapefile and made a union of all entity and an envelope.
As it said in GeoPandas doc, after these 2 geometric manipulations it returns GeoSeries.
But how can I convert my GeoSeries to a GeoDataFrame to finally export it to a shapefile ?
I try this on point shapefile but my GeoDataFrame is empty…
import sys
import geopandas as gpd
shp = (sys.argv[1])
gdf = gpd.read_file(shp)
union = gdf.unary_union
env = union.envelope
envgdf = gpd.GeoDataFrame()
envgdf['geometry'] = env
envgdf.geometry.name
print("\nGeoDataFrame :\n", envgdf)
Returns :
GeoDataFrame :
Empty GeoDataFrame
Columns: [geometry]
Index: []
Best Answer
GeoDataframe
now accepts ageometry
keyword argument. Taking advantage of that, we can writeThis automatically sets the
GeoSeries
as the geometry column.