2

I am trying to use gdal_polygonize to create a polygon from a binary raster.

My code is:

os.system('gdal_polygonize.py ' + filename + ' -f ESRI Shapefile ' + shapefile)

where filename is a string file path with a '.tif' extension and 'shapefile' has a .shp

I am receiving the following error message:

Creating output Shapefile of format ESRI.
Traceback (most recent call last):
  File "/usr/bin/gdal_polygonize.py", line 164, in <module>
    dst_ds = drv.CreateDataSource( dst_filename )
AttributeError: 'NoneType' object has no attribute 'CreateDataSource'

I have browsed the internet for help but to no avail. I am running the programme from NXclient on a windows 7 machine.

Any help would be greatly appreciated.

Becky

2
  • 2
    Try directly the command gdal_polygonize.py my_tif.tif -f "ESRI Shapefile" my_shapefile.shp to be sure that the os.system call is not the problem. You also forgot the double quotes for "ESRI Shapefile"
    – ThomasG77
    Commented May 8, 2013 at 22:23
  • Thanks for that - The problem was solved simply by putting in the quotation marks in : "ESRI Shapefile"
    – Becky
    Commented May 9, 2013 at 9:34

1 Answer 1

1

The problem was that I didn't use quotation marks when specifying output format: "ESRI Shapefile"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.