views:

277

answers:

4

I am trying to figure out how to plot WGS84 latitude/longitude points on a bitmap but cannot figure out the math required to turn lat/lon points into coordinates that would be plottable. Could anyone give me some pointers or examples on how to do this?

thanks

Colin

+4  A: 

Turning latitude longitude into x, y for plotting on a flat 2d surface like a bitmap is a large and complicated topic.

For general information about this see map Projections on wikipedia.

In general websites like google maps and bing solve this problem by using a mercator projection on a perfect sphere which can easily cover most of the earth (except the north/south pole) and be 'good enough' for most purposes. However, those are some big ifs and it really depends on how accurate your pictures need to be and what they need to preserve.

Unfortunately I don't know delpi well enough to provide source code but the math for mercator projections is well documented here.

If accuracy is not an issue at all and your points are 'close together', the simplest method would be to simply use a constant factor and offset to shift latitude/longitude into x and y values that fit onto your bitmap.

This might make a slightly squish your pictures in the north/south direction but in general will produce pictures much like mercator without the natural logarithms and sin/tangent calls.

MerickOWA
+2  A: 

You might have a look at the Mercator Projection Demo, with Delphi source code:

http://delphiforfun.org/programs/MercatorDemo.htm

Greg Bishop
A: 

As already mentioned by MerickOWA, there is no right answer to the question as it depends on the scale you are working at, and the accuracy you require. This will largely be determined by what is on the .bmp you are discussing. If it is a global map in Mercator projection, then Greg's answer will give you some pointers. If it is a local map, then it will depend on the datum the map is using, and the projection used (and the datum will largely be determined by the national authority of the country in question). Having said all that, if what you want to do is just project a GPS provided Lat Lon (GS84 datum) onto a local map covering an area < 6° of Latitude, then you could do worse than projecting the WGS84 Lat Lon to a WGS84 UTM projection, then scaling (and possibly)rotating the map to fit at 2 known coordinates.

The link here should give some help http://www.uwgb.edu/dutchs/usefuldata/utmformulas.htm

HMcG
When I say a bitmap I am really reffering to a Timage with a blank bitmap I do not wish to overlay the coords ona map or image just to have them plotted on the screen in the relative positions. Its more how to take a lat lon and convert to an XY rather than overlaying on an image
A: 

Hi Colin,

Did you try The World Coordinate Converter: http://twcc.free.fr ?

Clement Ronzon