[gdal-dev] max y is less than min y

Frank Warmerdam warmerdam at pobox.com
Sun Apr 4 23:06:41 EDT 2010


weixj2003ld wrote:
> I read a .tif file ,and use the following code to get the MinX,MinY,MaxX 
> and MaxY of the coordation of the tif image.
> ...
> double *m_AdGeoTransform=new double[6];
> poDataset->GetGeoTransform(AdGeoTransform);
> nX=poDataset->GetReasXsize();
> nY=poDataset->GetReasYsize();
>  
> MinX=AdGeoTransform[0];
> MinY=AdGeoTransform[3];
>  
> MaxX =AdGeoTransform[0]+nX*AdGeoTransform[1]+nY*AdGeoTransform[2];
> MaxY=AdGeoTransform[3]+nX*AdGeoTransform[4]+nY*AdGeoTransform[5];
> ...
>  
> I find that MaxY is less than MinY ,why?
> Thk u in advance.

Wei,

GeoTransform[3] is the the Y origin, that is the Y value of the top left
corner of the top left pixel.    In a normal georeferenced image this is
the north west corner, and since "northing" (Y) increases as you move
to the north the GeoTransform[3] value will generally be the maximum Y
for the image.

So I think you just need to compute:

   MaxY = AdGeoTransform[3];
   MinY = AdGeoTransform[3] + nX*AdGeoTransform[4]+nY*AdGeoTransform[5];

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the gdal-dev mailing list