I try to export an shp
from Python
using geopandas
with this:
#Create a output path for the data
out = r"C:\Users\hhh\Desktop\ge.shp"
## Write those rows into a new Shapefile
df.to_file(out)
and I get this error:
ValueError: Invalid field type <class 'shapely.geometry.polygon.Polygon'>
The type of the df
is geopandas.geodataframe.GeoDataFrame
and I have done some geoprocessing which may be causing errors at the output. Also, it gives an output but when I open it, it shows nothing and the attribute table is also empty.
I checked this with another case by taking a subset from an shp read in python:
out = r"C:\Users\hhh\Desktop\hid.shp"
selection = data[0:50]
selection.to_file(out)
and it worked.
What can be causing this problem in the first case?
Best Answer
Shapefiles have some limitations, including:
In both cases you will get errors when trying to write a GeoDataFrame to a shapefile.