[gdal-dev] how to create a latitude map

Frank Warmerdam warmerdam at pobox.com
Wed Jul 9 09:13:48 EDT 2008


Yann Chemin wrote:
> Hello,
> 
> how would you go to write a GDAL-based code to return latitude (or
> longitude) as pixel values?

Yann,

You are wanting to write this in C/C++?

Loosely speaking I think you need to:

  o Create a GDAL GenImgProjTransformer from the image to lat/long.
  o Invoke the transformer for each pixel in the image, and record the
    results to a new output band/file.

You might look at gdal/apps/gdaltransform.cpp as an example of how to
create an image transformer (a function for transforming from image
coordinates to some other image or georeferenced coordinates).

Invoking a transformer is a bit expensive, so call it on an array of
locations for a whole line, rather than making a call for each pixel.

The following docs may be of help:

   http://www.gdal.org/ogr/osr_tutorial.html
   http://www.gdal.org/gdal__alg_8h.html#7671696d085085a0bfba3c3df9ffcc0a

Good luck,
-- 
---------------------------------------+--------------------------------------
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    | President OSGeo, http://osgeo.org



More information about the gdal-dev mailing list