<html 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=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
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:#954F72;
text-decoration:underline;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style></head><body lang=EN-AU link=blue vlink="#954F72"><div class=WordSection1><p class=MsoNormal>Hi Evan,</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Ok I thought it might have been at least partially intended. Unfortunately, I think the use case the change is addressing is not what the majority of users are thinking of when they choose projwin. </p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>As Rutger pointed out, the Clipper tool in QGIS 2.14 onwards is now incapable of producing an output that lines up with input, unless the user spends some time doing coordinate math to calculate a precise projwin. That’s a pretty major efficiency loss. Questions about how to clip a raster without resampling or alignment changes appear regularly on stackexchange (see <a href="http://gis.stackexchange.com/questions/201204/qgis-clipper-tool-misaliagnment">http://gis.stackexchange.com/questions/201204/qgis-clipper-tool-misaliagnment</a> , and <a href="http://gis.stackexchange.com/questions/203664/clip-a-tiff-raster-image-using-a-bounding-box-with-python">http://gis.stackexchange.com/questions/203664/clip-a-tiff-raster-image-using-a-bounding-box-with-python</a>) and gdal_translate with projwin is regularly recommended as the most viable solution.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Jukka, I tried gdal_warp with -te and -tap (one must also input -tr). It was better in that the cell sizes didn’t change, but the output cells moved slightly northwest, such that the center of the input cell became the lower right corner of the output cell. I guess that could be fixed by using gdal_edit with -a_ullr to nudge the output back into place, but that’s still extra work that shouldn’t be necessary.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I think it would be better if projwin’s functionality reverted to its previous behaviour as a default, and that an additional flag be made available for people who do want strict conformance with their specified bounding box as part of a resampling operation.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Either way, the way projwin works in different versions needs to be made explicit in the documentation. </p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Regards</p><p class=MsoNormal>Lauren<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman",serif'><o:p> </o:p></span></p><div style='mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal style='border:none;padding:0cm'><b>From: </b><a href="mailto:even.rouault@spatialys.com">Even Rouault</a><br><b>Sent: </b>Thursday, 28 July 2016 2:10 AM<br><b>To: </b><a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>; <a href="mailto:jukka.rahkonen@maanmittauslaitos.fi">Jukka Rahkonen</a><br><b>Cc: </b><a href="mailto:leobrien@gmail.com">Lauren O'Brien</a><br><b>Subject: </b>Re: [gdal-dev] gdal_translate with -projwin possible bug</p></div><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman",serif'><o:p> </o:p></span></p><p class=MsoNormal>Hi Lauren,</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>This change was semi intended as far as I can remember (the change that leads </p><p class=MsoNormal>to that was intended, the effect in this use case not) . It dates back to GDAL </p><p class=MsoNormal>2.1.0 where the VRT driver can now support floating point coordinates for </p><p class=MsoNormal>SrcWin / DestWin, and gdal_translate was updated accordingly to not round to </p><p class=MsoNormal>integer pixel coordinates deduced from world coordinates specified through -</p><p class=MsoNormal>projwin. Sub pixel accuracy makes sense when using with a resampling that is </p><p class=MsoNormal>not nearest neighbour with the -r switch. But indeed for nearest neighbour, it </p><p class=MsoNormal>might result in a non intended shift.</p><p class=MsoNormal>Perhaps a good compromise would be to round to integer for nearest neighbour </p><p class=MsoNormal>only ?</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Regarding Jukka's comment,</p><p class=MsoNormal>> I am sure that there are also users who consider that it is a bug if the</p><p class=MsoNormal>> output does not exactly match -projwin.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Using -a_ullr is a way of definining the output bounds for sure.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Even</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>> Hello all,</p><p class=MsoNormal>> </p><p class=MsoNormal>> I've noticed what I think may be a bug with gdal_translate, just looking</p><p class=MsoNormal>> for further information before deciding whether to report it.</p><p class=MsoNormal>> </p><p class=MsoNormal>> In version 1.11.4 and earlier, using the -projwin tag to subset a raster</p><p class=MsoNormal>> produces an output whose cell alignment and content matches the source</p><p class=MsoNormal>> dataset - it just grabs any cells that intersect the box and writes them to</p><p class=MsoNormal>> the output.</p><p class=MsoNormal>> </p><p class=MsoNormal>> In v2.1.0 (at least in a Windows environment), this no longer occurs. The</p><p class=MsoNormal>> output raster is distorted to match the exact extent of the -projwin</p><p class=MsoNormal>> coordinates. No resampling is involved, but the cell origins shift, and the</p><p class=MsoNormal>> cell sizes are either shrunk or stretched slightly to conform to the</p><p class=MsoNormal>> projwin box. This is a substantial change in behaviour which doesn't appear</p><p class=MsoNormal>> to have been documented.</p><p class=MsoNormal>> </p><p class=MsoNormal>> From my point of view, its an unwelcome change. I've been using</p><p class=MsoNormal>> gdal_translate with -projwin and vsicurl to clip out sections of large</p><p class=MsoNormal>> national datasets without having to download the whole file first, and</p><p class=MsoNormal>> without needing to know things like the source dataset origin, cellsize etc</p><p class=MsoNormal>> in order to ensure output aligns with input. I need each dataset I clip out</p><p class=MsoNormal>> to 'stack' properly, and to represent an unaltered subset of the source</p><p class=MsoNormal>> data.</p><p class=MsoNormal>> </p><p class=MsoNormal>> Please let me know if this is a true bug or just an undocumented change,</p><p class=MsoNormal>> and/or if there's a better alternative command to use.</p><p class=MsoNormal>> </p><p class=MsoNormal>> Regards,</p><p class=MsoNormal>> Lauren O'Brien</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>-- </p><p class=MsoNormal>Spatialys - Geospatial professional services</p><p class=MsoNormal>http://www.spatialys.com</p><p class=MsoNormal><o:p> </o:p></p></div></body></html>