This script runs but does not create the shapefile files. It works, however, if I were to replace the driver for GeoJSON and create a GeoJSON file. Context: I'm working through Chris Garrard's "Geoprocessing with Python".

from osgeo import ogr
shp_fn = r'C:\Users\imper\Desktop\New folder\shp_test.shp'
shp_driver = ogr.GetDriverByName('ESRI Shapefile')
shp_ds = shp_driver.CreateDataSource(shp_fn)
if shp_ds is None:
    sys.Exit('Could not create {0}.'.format(shp_fn))
  • 1
    You can't actually create the shapefile files on disk without first specifying the CRS, geometry type, and field definitions. I suspect your expectation of what happens after CreateDataSource is incorrect. – Vince Nov 15 '20 at 13:06

Your Answer

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

Browse other questions tagged or ask your own question.