Wednesday, 9 May 2018

raster - Squaring pixels of GeoTIFF using GDAL


I have a GeoTiff that has been supplied to me with non square pixels (I suspect due to reprojection to lat lon at some point). However the next step in my processing chain requires a Arc ASCII grid as input and so I need square pixels.


To save me trying to guess the original projection can any one tell me how to use GDAL to resample my image so the pixels become square?



Answer



It's not something I've tried, but I think you can do it with gdalwarp:


gdalwarp -tr 10.0 -10.0 -r bilinear src.tif dst.asc

You would choose a -tr value based on the smallest value of the source's resolution, remembering to negate the y scale if it's a top-down image. gdal_translate has an -outsize parameter that might do the job, but it may just truncate the image, or at best use nearest neighbour interpolation.


I'd be interested in what you find, because sooner or later it's going to happen to someone else!


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...