<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Verdana;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:"Segoe UI";
panose-1:2 11 5 2 4 2 4 2 2 3;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:"Courier New";}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">Hi everyone,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New"">gdal_rasterize -burn 0 -dialect SQLITE -sql "SELECT * FROM MyLayer WHERE (Name IS NOT '01') AND (Name IS NOT '02')" myfile.kmz existingfile.tif<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">But when I try the same, from the Python bindings it fails:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Courier New";color:black">query =
</span><b><span style="font-size:8.5pt;font-family:"Courier New";color:green">"SELECT * FROM IceLayer WHERE (Name IS NOT '01') AND (Name IS NOT '02')"<br>
</span></b><span style="font-size:8.5pt;font-family:"Courier New";color:black">myoptions = gdal.RasterizeOptions(</span><span style="font-size:8.5pt;font-family:"Courier New";color:#660099">burnValues</span><span style="font-size:8.5pt;font-family:"Courier New";color:black">=</span><span style="font-size:8.5pt;font-family:"Courier New";color:blue">0</span><span style="font-size:8.5pt;font-family:"Courier New";color:black">,
</span><span style="font-size:8.5pt;font-family:"Courier New";color:#660099">SQLStatement</span><span style="font-size:8.5pt;font-family:"Courier New";color:black">=query,
</span><span style="font-size:8.5pt;font-family:"Courier New";color:#660099">SQLDialect</span><span style="font-size:8.5pt;font-family:"Courier New";color:black">=</span><b><span style="font-size:8.5pt;font-family:"Courier New";color:green">"SQLITE"</span></b><span style="font-size:8.5pt;font-family:"Courier New";color:black">)<br>
gdal.Rasterize(tif, kmz, </span><span style="font-size:8.5pt;font-family:"Courier New";color:#660099">options</span><span style="font-size:8.5pt;font-family:"Courier New";color:black">=myoptions)<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Courier New";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal">With:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New"">Traceback (most recent call last):<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New""> File "my_script.py", line 65, in <module><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New""> create_ids_mask(lcc, working_dir, buffered_coastline)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New""> File "my_script.py", line 54, in my_function<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New""> gdal.Rasterize(tif, kmz, options=myoptions)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New""> File "c:\Python36\lib\site-packages\osgeo\gdal.py", line 1085, in Rasterize<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New""> return wrapper_GDALRasterizeDestName(destNameOrDestDS, srcDS, opts, callback, callback_data)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New""> File "c:\Python36\lib\site-packages\osgeo\gdal.py", line 3050, in wrapper_GDALRasterizeDestName<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New""> return _gdal.wrapper_GDALRasterizeDestName(*args)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New"">RuntimeError: Cannot create X:\localpath\existingfile.tif<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I checked that the paths are correctly passed. What else could be the issue?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:#303030">Benjamin Deschamps
<br>
<br>
Physical Sciences Specialist<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="FR" style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:#303030">Canadian Ice Service, Meteorological Service of Canada<br>
Environment and Climate Change Canada / Government of Canada <br>
</span><span lang="FR" style="font-size:10.0pt;font-family:"Verdana","sans-serif""><a href="mailto:Benjamin.Deschamps@canada.ca"><span style="color:blue">Benjamin.Deschamps@canada.ca</span></a><span style="color:#303030"> / Tel: 613-943-4293
<br>
<br>
Spécialiste des sciences physiques<o:p></o:p></span></span></p>
<p class="MsoNormal"><span lang="FR" style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:#303030">Service Canadien des Glaces, Service Météorologique du Canada,
<br>
Environnement et Changement climatique Canada / Gouvernement du Canada <br>
</span><a href="mailto:Benjamin.Deschamps@canada.ca"><span lang="FR" style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:blue">Benjamin.Deschamps@canada.ca</span></a><span lang="FR" style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:#303030">
/ Tél. : 613-943-4293<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="FR-CA"><o:p> </o:p></span></p>
</div>
</body>
</html>