[gdal-dev] Building a Mercator Image from Un-projected data..Major confusion and help requested.

Christopher Barker Chris.Barker at noaa.gov
Tue Nov 3 12:25:29 EST 2009

Cassanova, Bill wrote:
> My question is how does this convert to pixel location FROM 
> the data set and then INTO the image.

Each pixel center is at a given lat-long in each image, but with 
different projections, these are different. So you need to do:

pixel1 -> lat-long

lat-long -> meters_in_new_projection

meters_in_new_projection -> pixel2

This is going to take a bit of arithmetic.

However, a pixel in one image is not going to map exactly to one pixel 
in the other -- so you need to do some type of interpolation. nearest 
neighbor is easy, but not very pretty. Other methods are more complicated.

gdalwarp does all this for you, and does it well, so I'd either call out 
to the command line program (easiest), or look at the gdalwarp source 
code, and see if you can wrap it up in your app. No need to start from 


Christopher Barker, Ph.D.

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov

More information about the gdal-dev mailing list