[gdal-dev] Croping raster map but keeping up the grid without resampling

Jukka Rahkonen jukka.rahkonen at mmmtike.fi
Tue Oct 30 07:34:50 PDT 2012


Luis Lisboa <luislisboa1975 <at> gmail.com> writes:

> 
> 
> Greetings
>  
> I have a raster image and I want to crop a piece of it(usin -te) but I want to
keep:
> - the same spatial resolution (use -tr )
> - and keep the same grid (avoiding mismatching from original image).
> Is this possible? If yes, how? because all my attempts there is a slightly
mismatch between original and new.

Use ogrinfo and calculator

If ogrinfo is listing this
Origin = (199949.000000000000000,6977074.000000000000000)
Pixel Size = (0.500000000000000,-0.500000000000000)

then you can calculate the extents to suit exactly with the original pixels. If
 X-values of the extents are (199949 + (n x 0.50)) and Y-values (6977074 + (n x
0.50)) and you are using the nearest neighbor resampling the result should be
what you want.  

-Jukka Rahkonen- 



More information about the gdal-dev mailing list