[gdal-dev] Problem with pixel/line coordinates

Alexander Bruy alexander.bruy at gmail.com
Fri Jun 18 13:20:22 EDT 2010


Thanks for your explanation, Frank! Now it works fine

On Thu, 17 Jun 2010 13:59:46 -0400
Frank Warmerdam <warmerdam at pobox.com> wrote:

> Alexander,
> 
> I believe the addition of 0.5 in the above is incorrect.  In the
> simple, non-rotated case, all values from geoTransform[0]
> to geoTransform[0] + geoTransform[1] would be on the 1st
> pixel (ie. pX = 0).  As you have coded it, when you are half
> way across the pixel you are switching into the next one.
> 
> Keep in mind that (geoTransform[0],geoTransform[3])
> is the top left corner of the top left pixel - not the center.
> 
> > def pixelToMap( pX, pY, geoTransform ):
> >  mX, mY = applyGeoTransform( pX, pY, geoTransform )
> >  return mX, mY
> 
> Conversely, here if pX and pY are coming in as integer
> rather than floating point values, then you will likely want
> to add half a pixel before transforming so that you get
> the geoeferenced location of the center of the pixel rather
> than the upper left corner.


-- 
Alexander Bruy


More information about the gdal-dev mailing list