[gdal-dev] Rasterize command works from utility but not Python binding

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[gdal-dev] Rasterize command works from utility but not Python binding

Deschamps, Benjamin (AAFC/AAC)

Hi everyone,


I am burning values from a KMZ into an existing GeoTiff. When I do it on the command line using gdal_rasterize (2.1.3), it works correctly:


gdal_rasterize -burn 0 -dialect SQLITE -sql "SELECT * FROM MyLayer WHERE (Name IS NOT '01') AND (Name IS NOT '02')" myfile.kmz existingfile.tif


But when I try the same, from the Python bindings it fails:


query = "SELECT * FROM IceLayer WHERE (Name IS NOT '01') AND (Name IS NOT '02')"
myoptions = gdal.RasterizeOptions(burnValues=0, SQLStatement=query, SQLDialect="SQLITE")
gdal.Rasterize(tif, kmz,




Traceback (most recent call last):

  File "my_script.py", line 65, in <module>

    create_ids_mask(lcc, working_dir, buffered_coastline)

  File "my_script.py", line 54, in my_function

    gdal.Rasterize(tif, kmz, options=myoptions)

  File "c:\Python36\lib\site-packages\osgeo\gdal.py", line 1085, in Rasterize

    return wrapper_GDALRasterizeDestName(destNameOrDestDS, srcDS, opts, callback, callback_data)

  File "c:\Python36\lib\site-packages\osgeo\gdal.py", line 3050, in wrapper_GDALRasterizeDestName

   return _gdal.wrapper_GDALRasterizeDestName(*args)

RuntimeError: Cannot create X:\localpath\existingfile.tif


I checked that the paths are correctly passed. What else could be the issue?




Benjamin Deschamps

Physical Sciences Specialist

Canadian Ice Service, Meteorological Service of Canada
Environment and Climate Change Canada / Government of Canada
[hidden email] / Tel: 613-943-4293

Spécialiste des sciences physiques

Service Canadien des Glaces, Service Météorologique du Canada,
Environnement et Changement climatique Canada / Gouvernement du Canada
[hidden email] / Tél. : 613-943-4293


gdal-dev mailing list
[hidden email]