Question : linear approximation of lat/long

Hi,
I'm working on a piece of software that will require me to plot a gps position (lat/long) on a street map. If I were to make raster images with a fixed image size say 200by200 pixels.
I would like to leniarly estimate the positions within these files... for example, I know the lat/long at the corners of my (200by200) pixel image.... and I want to plot the position i have (the lat/long of which lie within these boudaries)... what would be the real world (miles/km) constraints on the image for the plot to be accurate? In other words... these 200 pixels would have to represent a maximum of 1, 5,10 or 100 miles?

I hope i've explained my question well enough!
Thanks

Answer : linear approximation of lat/long

Alumba,

The process you're describing is known as registering the raster image.  If you can find the four corners (you need at least three registration points to be valid), you translate between the two coordinate systems through a simple translation.  Of course, since you're limited by the actual pixel resolution, there will rarely be a single pixel that corresponds exactly to a given lat / long pair.

For example, lets say you have 100 x 100 pixel image.  The top left corner is (40.0, 87.0) and the bottom right corner is (41.0, 88.0) in lat / long.  I'm using whole numbers so I don't have to grab a calculator ;-).  Let's say you want to figure out where 40.25 degrees latitude falls on the image.

testPixelLat = (((testLat - leftLat) / abs(leftLat - rightLat)) * abs((leftPixel - rightPixel))) + leftPixel
textPixelLat = (((41.25 - 41.00) / abs(40.0 - 41.0)) * abs(0 - 100)) + 0 = 25

It's the same process for the longitude axis.  Keep in mind you may have to change the signs depending on what coordinate system you're translating from / to.  I used the simplest case of northeast orientation for both the map and the pixel image which is rarely the case.

Cheers,
Chris
Random Solutions  
 
programming4us programming4us