Quantcast
Channel: Python can't read shapefile - Geographic Information Systems Stack Exchange
Viewing all articles
Browse latest Browse all 3

Python can't read shapefile

$
0
0

I am trying to open a shapefile with Jupyter notebook, but I can't get it to open. The shapefile is located in the same folder as my workbook, and Python can't identify it even if I use the full path.

import shapefile as shpimport matplotlib.pyplot as pltsf = shp.Reader(r'C:\Users\Public\Documents\1-11-99n.shp')

ShapefileException: Unable to open C:\Users\Public\Documents\1-11-99n.dbf or C:\Users\Public\Documents\1-11-99n.shp.

Opening it with fiona and geopandas does not work either.

import fionashape = fiona.open("1-11-99n.shp")

and

import geopandas as gpshp = gp.GeoDataFrame.from_file('1-11-99n.shp')print (shp)

both end up with

CPLE_OpenFailedError: b'Unable to open 1-11-99n.shx or 1-11-99n.SHX.Try --config SHAPE_RESTORE_SHX true to restore or create it'

I know this might be a trivial issue, but I am new to using shapefiles and spatial Python libraries so I really don't know how to work around this issue.


Viewing all articles
Browse latest Browse all 3

Trending Articles