The documentation for GDALDataset::GetGeoTransform says some things that are rather confusing.

Fetches the coefficients for transforming between pixel/line (P,L) raster space, and projection coordinates (Xp,Yp) space.

Xp = padfTransform[0] + P*padfTransform[1] + L*padfTransform[2];
Yp = padfTransform[3] + P*padfTransform[4] + L*padfTransform[5];

In a north up image, padfTransform[1] is the pixel width, and padfTransform[5] is the pixel height.

The upper left corner of the upper left pixel is at position (padfTransform[0],padfTransform[3]).

The default transform is (0,1,0,0,0,1) and should be returned even when a CE_Failure error is returned, such as for formats that don't support transformation to projection coordinates.

If this is a matrix, it makes sense that Pixel_X is at 1,1 and Pixel_Y is at 2,2.

Here is my question:

So should the equation for Yp be:

Yp = padfTransform[3] + L*padfTransform[4] + P*padfTransform[5];

in which the positions of L and P are swapped?

Or if I am confused about something, can someone help me get unconfused?



For a north up image with no rotation (i.e. padfTransform[4] == padfTransform[2] == 0), the formula simply becomes:

Xp = padfTransform[0] + P*padfTransform[1];
Yp = padfTransform[3] + L*padfTransform[5];

# Where P = column number and L = row number

i.e add the starting X (or Y) to the column (or row) number multiplied by the pixel width (or height).

The rotation terms may be what's tripping you up...? When a pixel is rotated, the Y skew needs to be considered when calculating the X map coordinate and the X skew needs to be considered when calculating the Y map coordinate. There's a quite detailed explanation in the wikipedia article on world files.

  • That there is rotation is what was tripping me up. So can you tell me what P and L stand for? I naively supposed that P was Pixel dimension and L was Line dimension (the lines between pixels). Yes, that is as foolish as a sophomore reasoning with senior. In that vein, what do those letters stand for? – philologon Mar 7 at 0:44
  • 1
    @philologon P is column number, and L is row number. These are "coordinates" on the raster image. – Mike T Mar 7 at 0:47
  • Thanks. I now see it is right there in the documentation. I always find a way to embarrass myself in these kinds of things, usually by skimming too fast. – philologon Mar 7 at 0:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.