Sign in to follow this  

Drawing lat/lon points on a map

This topic is 3666 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

As part of a current project, I require a map showing the location of various cities. I already know the latitude and longitude of these cities, and would like to convert this into a map location. Does anyone know a formula for doing this? Im sure I managed to do it in a previous instance of this project, which I lost a while back, but I cant for the life of me remember how I did it. I know I could just work out the location on the map and save that in the data file, however I would like to use multiple maps (world map, continental map, country map), which would just make the data storage a mess. I guess the answer lies in working out the lon/lat coverage of the map, and translating this to pixels. However the fact that lat/lon 0/0 is in the middle rather than the top left corner is confusing my poor brain... The project is in C#, however this is probably more of a generic question and a pseudo algorithm will suffice. Any advice greatly received

Share this post


Link to post
Share on other sites
I'm guessing you want the 3-dimensional cartesian coordinates, given the location in spherical coordinates. You can use:

x = R * sin(a) * cos(b)
y = R * sin(a) * sin(b)
z = R * cos(a)

Where R is the earth radius, a is the latitude and b is the longitude.

EDIT: If you need a 2D image you will need to use some form of projection, like stereographic projection for example.

Share this post


Link to post
Share on other sites
Ah I see, I guess you want something along the lines of the Mercator projection or a derivation of it Miller cylindrical projection. The projection is described with the appropriate formulas in the wikipedia article.

Hope this helps!

EDIT: They are several more projections to choose from; these two seemed to produce the result your were after given your screenshots from Great Circle Mapper.

Share this post


Link to post
Share on other sites
Mercator is fairly standard for a map projection (though it is unfair for the southern hemisphere).

http://earth-info.nga.mil/GandG/geotrans/ is some free c source which handles a lot of datum conversion and projections. Then converting projection to screen is fairly trivial. Mercator can produce everything in a false easting/northing coords from a 0,0 lat/lon (easiest to work with) that map easily into y,x .

http://www.codeplex.com/SharpMap is a C# based GIS project as well, which might have everything you want.

http://www.gdal.org/ is another project which may have some applicable stuff for you.

Between these and Omid's links below you should have all the knowledge you need to created what you want.

Share this post


Link to post
Share on other sites

This topic is 3666 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this