How do I plot latitude/longitude coordinates on the screen?
Asked Answered
G

4

5

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

Gyp answered 17/9, 2010 at 21:41 Comment(3)
Which projection are you using? If you don't know what that question means, then consider "learn about map projections" to be your first pointer.Asleep
Also, when you say you can't "figure out" the math, does that mean you have found the conversion formulas and don't know how to apply them in your program, or does it mean you don't know what the formulas are?Asleep
I am talking about how to convert a lat / lon to an XY to plot on a bitmapGyp
P
3

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

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

Paget answered 18/9, 2010 at 5:59 Comment(0)
R
5

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.

Rasberry answered 17/9, 2010 at 22:2 Comment(0)
P
3

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

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

Paget answered 18/9, 2010 at 5:59 Comment(0)
E
0

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

Enplane answered 18/9, 2010 at 12:11 Comment(1)
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 imageGyp
L
0

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

Lumisterol answered 20/9, 2010 at 7:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.