views:

52

answers:

2

I realise this is potentially not a programming question, however its a problem I keep bumping into as a programmer, so I figure others here might have useful knowledge to share.

I have a map of a region of the earth (it could be any, but here's an example) how should I determine the projection used in the map and then how should I programatically transform latitude and longitude coordinates into pixel positions on the image.

At the moment I have matlab code to open the image and plot the resulting (x,y) coord, but I can't figure out how to convert lat/longs to x,y!

Any help at all would be greatly appreciated.

A: 

Geographic coordinates are a variation of spherical coordinates. You can transform them to normal coordinates:

x = r * sin(90 - lat) * cos(lon)
y = r * sin(90 - lat) * sin(lon)
z = r * cos(90 - lat)

This is not really accurate because Earth is not exactly a sphere. Depending on the type of the map there are several ways to obtain 2D coordinates from these. The image may be projected from the sphere to a cylinder or two planes.

These links might help:

stribika
That's not always the case tho - for example any map could be Mercator Projection, Robinson Projection or any one of the ones listed here: http://www.radicalcartography.net/?projectionref . My problem is determining *which* of these projections a given image is (obviously you can do this by inspection, but its very laborious and inefficient!)
JP
A: 

It turns out that programatically calculating the projection of a map is a complex task of image processing. The way I managed to get around this problem is simply using maps that have well defined projections - for example Google maps use the Mercator projection, as do most maps of the UK (as our British Reference Grid is based on the Universal Transverse Mercator).

I hope this helps someone else out!

JP

related questions