Converting Longitude & Latitude to X Y on a map with Calibration points

Jorge picture Jorge · Sep 2, 2009 · Viewed 63.6k times · Source

If i have a jpeg map with size sizeX, sizeY

and some calibration points on the map (X, Y, Lon, Lat)

What would be the algorithm for calculating the corresponding XY point in the map with a given Longitude / Latitude pair?

Answer

Gubatron picture Gubatron · Dec 30, 2010

Here's what worked for me, without so much bs.

int x =  (int) ((MAP_WIDTH/360.0) * (180 + lon));
int y =  (int) ((MAP_HEIGHT/180.0) * (90 - lat));

The lat,lon coordinates were given to me by Android devices. So they should be in the same standard used by all Google Earth/Map products.