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

Becky
  • 627
  • 2
  • 6
  • 16
  • 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 May 08 '13 at 22:23
  • Thanks for that - The problem was solved simply by putting in the quotation marks in : "ESRI Shapefile" – Becky May 09 '13 at 09:34

1 Answers1

1

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

Becky
  • 627
  • 2
  • 6
  • 16