<div dir="ltr">
<div>Hi,</div><div><br></div><div>I am trying to clip a raster using a 
polygon layer. I want to specify a where clause to select one polygon 
feature from the polygon layer and subset the raster <b>only </b>for that one polygon feature.</div><div><br></div><div>I am not getting the intended results with this line of code:</div><div><br></div><div>
<pre><code><span>ds </span><span>=</span><span> gdal</span><span>.</span><span>Warp</span><span>(</span><span>'output.tif'</span><span>,</span><span> </span><span>'input.tif'</span><span>,</span><span> format </span><span>=</span><span> </span><span>'GTiff'</span><span>,</span><span> \
               cutlineDSName </span><span>=</span><span> </span><span>'parcel.shp'</span><span>,</span><span> \
               cutlineSQL </span><span>=</span><span> </span><span>'SELECT * FROM parcel'</span><span>,</span><span> \
               cutlineWhere </span><span>=</span><span> </span><span>'name = "first"'</span><span>)</span><span>

</span><span>if</span><span> ds </span><span>is</span><span> </span><span>None</span><span>:</span><span>
    </span><span>print</span><span>(</span><span>'Failed'</span><span>)</span><span>
</span><span>else</span><span>:</span><span>
    </span><span>print</span><span>(</span><span>'Success'</span><span>)</span><span>
</span><span># prints Success but gives same result as without the cutlineSQL and cutlineWhere options</span></code></pre>

</div><div>Problem is also explained in detail on <a href="https://gis.stackexchange.com/questions/369065/incorrect-results-while-cropping-with-gdalwarp-and-cutlinesql" target="_blank">StackExchange</a> (with screenshots and sample data).<br></div><div>Could someone please let me know what I am missing? </div>

<div><br></div><div></div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Regards,</div><div>Prasun <br></div><div><br></div><div><br></div></div></div></div></div>