<div dir="ltr"><div>Thanks Even.<br><br>I did try re-warping the cropped output to 3857 again and it does produce square pixels but at the expense of an additional warping operation<br><br></div>I'm just curious why the warping that is part of the -crop_to_cutline process is changing the pixel ratio while a regular, non-cropping warping makes them square<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 5, 2015 at 11:36 AM, Even Rouault <span dir="ltr"><<a href="mailto:even.rouault@spatialys.com" target="_blank">even.rouault@spatialys.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Le jeudi 05 février 2015 17:23:06, Jesse McGraw a écrit :<br>
<span class="">> I'm not sure whether this is a real issue or not but I thought I'd bring it<br>
> up, at the very least I'll learn something<br>
><br>
> When using "gdalwarp -cutline <shapefile> -crop_to_cutline" on an input<br>
> raster that is in EPSG:3857 with square-pixels the output raster, while<br>
> still EPSG:3857, now has non-square pixels.<br>
><br>
> They're aren't terribly non-square but aren't they supposed to be<br>
> completely square for EPSG:3857?<br>
<br>
</span>Perhaps... Actually the effet of -crop_to_cutline is exactly the same as<br>
manually passing the target extents with -te with the bounding box of the<br>
cutline.<br>
It is not possible to both preserve the extent extents and pixel size at the<br>
same time, due to width and height being integer values.<br>
So, in order to preserve pixel square, the extent should be modified a little<br>
bit. What is more appropriate is a matter of point of view I think.<br>
You can always re-run "gdalwarp tmp.tif out.tif" where tmp.tif is the output<br>
of first gdalwarp with -crop_to_cutline. And you should get square pixels I<br>
believe.<br>
<div class="HOEnZb"><div class="h5"><br>
><br>
> (FWIW, I see that there are tickets opened that reference similar issues<br>
> but they reference the output being shifted or the origin changing, not the<br>
> pixel shape changing)<br>
><br>
> For example:<br>
> #Warp our original .tif to EPSG:3857<br>
> $gdalwarp \<br>
> -t_srs EPSG:3857 \<br>
> -dstalpha \<br>
> -co TILED=YES \<br>
> "ENR_L33.tif" \<br>
> "./2.tif"<br>
><br>
> #See that the output pixels are square<br>
> $gdalinfo 2.tif<br>
> Origin = (-8577554.996301921084523,5421778.172851986251771)<br>
> Pixel Size = (43.677179501975118,-43.677179501975118)<br>
><br>
><br>
> #Now crop the image to a cutline<br>
> $gdalwarp \<br>
> -crop_to_cutline \<br>
> -dstalpha \<br>
> -cutline "./ENR_L33.shp" \<br>
> -cblend 10 \<br>
> -co TILED=YES \<br>
> "./2.tif" \<br>
> "./3.tif"<br>
><br>
> #See that output pixels are not square<br>
> $ gdalinfo 3.tif<br>
> Origin = (-8480047.445924906060100,5366376.137789577245712)<br>
> Pixel Size = (43.678439570399853,-43.675457269061347)<br>
><br>
><br>
> I ran some more tests and without the -crop_to_cutline option the output<br>
> pixels remain square<br>
><br>
> Thanks,<br>
> Jesse<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
Spatialys - Geospatial professional services<br>
<a href="http://www.spatialys.com" target="_blank">http://www.spatialys.com</a><br>
</font></span></blockquote></div><br></div>