# Drawing lat/lon points on a map

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

## 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 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 on other sites
thanks for the quick reply, i should have been a little more specific. Im looking for a 2D map, similar to Great Circle Mapper, ie:

##### 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 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.

1. 1
Rutin
31
2. 2
3. 3
4. 4
5. 5

• 13
• 17
• 11
• 10
• 14
• ### Forum Statistics

• Total Topics
632962
• Total Posts
3009506
• ### Who's Online (See full list)

There are no registered users currently online

×