Type error: reading ESRI shaping driver using OGR / GDAL in Python

I'm trying to use gdal_polygonize in Python to convert a raster to a shapefile with the following code:

# define output shapefile
driver_name = "ESRI Shapefile"
drv = ogr.GetDriverByName(driver_name)
dst_ds = drv.CreateDataSource(DataDirectory+OutputShapefile)
dst_layer = dst_ds.CreateLayer(DataDirectory+dst_layername, srs = Projection)

      

However, when reading in the driver by name, I keep the following error:

File "/home/s0923330/miniconda2/lib/python2.7/site-packages/osgeo/ogr.py", line 7262, in GetDriverByName
    return _ogr.GetDriverByName(*args)
TypeError: in method 'GetDriverByName', argument 1 of type 'char const *'

      

The raster I am reading works fine and I can open it with gdal from the command line without any problem. This is just a problem with OGR and Python. I was wondering if anyone has encountered this problem before? This is GDAL version 2.1.0.

Thank you in advance!

+3


source to share


1 answer


I solved this problem by commenting out the line in my code (or simply removing):



# from __future__ import unicode_literals
0


source







All Articles