0

I'm trying to create a shapefile [2D polygon type] with a Geodataframe, that result from a SQL made to a Oracle Spatial database. The SQL and the Geodataframe creation runs without errors, but when I try to use the GeoDataframe[.to_file] function, returns a few errors in the command:

geoparc.to_file('.../out/export.shp', driver='ESRI Shapefile')

Am I missing any parameters for the geometry type in .to file function?

How can I set the geometry type in the .to_file function?

geometry data type:

print(type(geoparc.geometry[0]))
 = class 'cx_Oracle.LOB'>

print(geoparc.geometry[0]) = 
POLYGON ((225117.58 411950.12, 225057.26803977 411941.365038031, 225058.343749989 411940.968749974, 225057.812500075 411939.468749988))

command:

geoparc.to_file('.../out/export.shp', driver='ESRI Shapefile')

Errors: geoparc.to_file('.../out/export.shp', driver='ESRI Shapefile');

...Python\Python35-32\lib\site-packages\geopandas\geodataframe.py", line 413, in to_file to_file(self, filename, driver, schema, **kwargs);

...Python\Python35-32\lib\site-packages\geopandas\io\file.py", line 106, in to_file schema = infer_schema(df);

...Python\Python35-32\lib\site-packages\geopandas\io\file.py", line 143, in infer_schema raise ValueError("Geometry column cannot contain mutiple " ValueError: Geometry column cannot contain mutiple geometry types when writing to file.

bumped to the homepage by Community 7 hours ago

This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.

0

Try

schema = {'geometry': 'Polygon'}

Then

geoparc.to_file('.../out/export.shp', schema=schema, driver='ESRI Shapefile')
  • I tried your solution but unfortunately the function .to_file return the errors below. Can you know the reason? ...\site-packages\geopandas\geodataframe.py", line 413, in to_file to_file(self, filename, driver, schema, **kwargs) site-packages\geopandas\io\file.py", line 110, in to_file schema=schema, **kwargs) as colxn: ...\site-packages\fiona\env.py", line 396, in wrapper return f(*args, **kwargs) ...\site-packages\fiona_init_.py", line 262, in open this_schema['properties'] = OrderedDict(schema['properties']) KeyError: 'properties' – Paulo Adão Feb 25 at 13:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.