[GIS] GeoPandas error when writing to_file() “ValueError: ‘long’ is not in list”

fionageopandasshapefile

I'm having a problem getting the "to_file()" function to work with GeoPandas:

    import geopandas as gpd
    f  = gpd.read_file('fin.shp')
    f.to_file('fout.shp')

Error Output:

    --------------------------------------------------------------------------- 
ValueError                                Traceback (most recent call last)
<ipython-input-14-6fdee04dae37> in <module>()
      1 f  = gpd.read_file('fin.shp')
----> 2 f.to_file('fout.shp')

C:\Python27\lib\site-packages\geopandas-0.1.0.dev-py2.7.egg\geopandas\geodataframe.pyc in to_file(self, filename, driver, **kwargs)
    308         filename = os.path.abspath(os.path.expanduser(filename))
    309         with fiona.open(filename, 'w', driver=driver, crs=self.crs, 
--> 310                         schema=schema, **kwargs) as c:
    311             for i, row in self.iterrows():
    312                 c.write(feature(i, row))

C:\Python27\lib\site-packages\fiona\__init__.pyc in open(path, mode, driver, schema, crs, encoding, layer, vfs)
    154         c = Collection(path, mode, 
    155                 crs=crs, driver=driver, schema=this_schema,
--> 156                 encoding=encoding, layer=layer, vsi=vsi, archive=archive)
    157     else:
    158         raise ValueError(

C:\Python27\lib\site-packages\fiona\collection.pyc in __init__(self, path, mode, driver, schema, crs, encoding, layer, vsi, archive, **kwargs)
    129             self.encoding = encoding
    130             self.session = WritingSession()
--> 131             self.session.start(self, **kwargs)
    132             self.encoding = encoding or self.session.get_fileencoding().lower()
    133 

C:\Python27\lib\site-packages\fiona\ogrext.pyd in fiona.ogrext.WritingSession.start (src/fiona/ogrext.c:15304)()

ValueError: 'long' is not in list

I'm using fiona 1.1.3 and GeoPandas 0.1 with Python 2.7 on Windows. It may be a problem with my ogrext.pyd dll in fiona.

Best Answer

Dave, it's a bug between Fiona and Geopandas. See https://github.com/kjordahl/geopandas/issues/93. Fiona 1.1.4 will be out shortly and will address this. For what it's worth, this is a problem that doesn't exist in Python 3 because there is only one integer type.

Related Question