[gdal-dev] gdalwarp coordinate alignment with -tap option

Gregory, Matthew matt.gregory at oregonstate.edu
Thu Feb 13 08:03:11 PST 2014


Hi Eli,

Eli Adam wrote:
> <matt.gregory at oregonstate.edu> wrote:
> > Hi all,
> >
> > We have been using -tap as a command-line argument to gdalwarp to
> > force pixels to be aligned with the origin (0,0) in the output
> coordinate system.
> >
> > We now have a situation where we want to specify a different 'snap'
> > coordinate for pixel alignment (e.g. (15,15)).  Is there a simple
> > mechanism for specifying this within gdalwarp that I'm overlooking?
> 
> Not exactly sure what you mean.  But you might try using -tr as well.
> I'm not exactly sure of how -tr and -tap relate from the docs,
> 
> -tr xres yres:set output file resolution (in target georeferenced units)
> -tap:(GDAL >= 1.8.0) (target aligned pixels) align the coordinates of
> the extent of the output file to the values of the -tr, such that the
> aligned extent includes the minimum extent.

Thanks for your help.  I left out some key information from my initial post which was that I am also passing -tr 30 30 as an argument to gdalwarp.  When using -tap along with this, the pixels are aligned with the origin.  What I really want is for the 30m pixels to have a corner at (15, 15) in the output projection.

The only way I've figured out how to do this is to first find the projected extents of the output image (via osr in python), modify these extents to snap to my desired snap window and then use the -te command line option to explicitly set the extent.

I was just looking for an obvious way to specify this just using gdalwarp command line options.

thanks, matt


More information about the gdal-dev mailing list