[gdal-dev] Rasterize command works from utility but not Python binding
Deschamps, Benjamin (EC)
benjamin.deschamps at canada.ca
Wed Jun 27 07:51:23 PDT 2018
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, options=myoptions)
With:
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?
Thanks,
Benjamin Deschamps
Physical Sciences Specialist
Canadian Ice Service, Meteorological Service of Canada
Environment and Climate Change Canada / Government of Canada
Benjamin.Deschamps at canada.ca<mailto:Benjamin.Deschamps at canada.ca> / 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
Benjamin.Deschamps at canada.ca<mailto:Benjamin.Deschamps at canada.ca> / Tél. : 613-943-4293
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20180627/8fe30fb7/attachment.html>
More information about the gdal-dev
mailing list