I have been searching on GIS for a solution to this essentially I have a shapefile .shp on my desktop also where I am saving this py script. The .shp also has the associated files. But when I try this code snippet I found on here I get back "couldn't load shapefile":
import osgeo import osgeo.ogr try: shapefile = osgeo.ogr.Open("world.shp") if shapefile: # checks to see if shapefile was successfully defined numLayers = shapefile.GetLayerCount() else: # if it's not successfully defined print "Couldn't load shapefile" except: # Seems redundant, but if an exception is raised in the Open() call, # you get a message print "Exception raised during shapefile loading" # if you want to see the full stacktrace - like you are currently getting, # then you can add the following: raise
Any ideas on why this would not work? I am using spyder and have gdal installed onto anaconda.