0

I am trying to read-in a shp file and can't seem to do it with the geopandas version 0.2.1. Here is the error:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-28-b4165d16b7f3> in <module>()
----> 1 gpd.GeoDataFrame.from_file('D:/NHDPlusV21/NHDPlusMS/NHDPlus06/NHDSnapshot/Hydrography/NHDFlowline.shp')

C:\Users\Rdebbout\AppData\Local\Continuum\Anaconda2\envs\nusc\lib\site-packages\geopandas\geodataframe.pyc in from_file(cls, filename, **kwargs)
    173 
    174         """
--> 175         return geopandas.io.file.read_file(filename, **kwargs)
    176 
    177     @classmethod

C:\Users\Rdebbout\AppData\Local\Continuum\Anaconda2\envs\nusc\lib\site-packages\geopandas\io\file.pyc in read_file(filename, **kwargs)
     26         else:
     27             f_filt = f
---> 28         gdf = GeoDataFrame.from_features(f, crs=crs)
     29 
     30     return gdf

C:\Users\Rdebbout\AppData\Local\Continuum\Anaconda2\envs\nusc\lib\site-packages\geopandas\geodataframe.pyc in from_features(cls, features, crs)
    185         """
    186         rows = []
--> 187         for f in features:
    188             if hasattr(f, "__geo_interface__"):
    189                 f = f.__geo_interface__

fiona\ogrext.pyx in fiona.ogrext.Iterator.__next__ (fiona/ogrext.c:20633)()

fiona\ogrext.pyx in fiona.ogrext.FeatureBuilder.build (fiona/ogrext.c:5188)()

fiona\_geometry.pyx in fiona._geometry.GeomBuilder.build (fiona/_geometry.c:3556)()

KeyError: 3002L

I have looked at the issue here and checked that 'id' 3002 exists, which it does as well as use Shapely to validate all of the geometries in the file.

I have another environment with the same versions of geopandas and a different version of fiona(1.5.1) that does work to load in the shp file, the one that doesn't work has fiona (1.7.0). Is it safe to say that this is a package issue with all this info? or am i missing something?

1

Does the issue present its self with other shapefiles too or just this one? I'm running geopandas 2.1.0 and fiona 1.7.3 and can't reproduce the issue w/ any files I have. Maybe you should try updating fiona?

I like to run this nifty little script every so often. It takes a little while to run but it will update every package you have installed.

import pip
from subprocess import call

for dist in pip.get_installed_distributions():
    call("pip install --upgrade " + dist.project_name, shell=True)
    print (dist.project_name)

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.