[GIS] Polygonize.py: AttributeError: ‘NoneType’ object has no attribute ‘CreateDataSource’

gdalpolygonizeraster

Given a topographic raster tif of an european country where elevations are simplyfied to either 0, either 200.

How to create a polygon ?


Comment: With the following polygonize.py command:

gdal_polygonize.py level200.tif -f "ESRI_Shapefile" level200.shp

I get to following error:

Creating output level200.shp of format ESRI_Shapefile.
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'

Best Answer

  1. AttributeError: 'NoneType' object has no attribute 'CreateDataSource' means the format -f is incorrect.
  2. Checking the manual : http://gdal.org/ogr/ogr_formats.html , the shape file format is ESRI Shapefile (no underscore).
  3. Try without underscore:

    gdal_polygonize.py level200.tif -f "ESRI Shapefile" level200.shp

    it works. :)

Related Question