longitude/latitude to cartesian coordinates

## Discussions

### General J2EE: longitude/latitude to cartesian coordinates

1. #### longitude/latitude to cartesian coordinates (6 messages)

Need to plot some points on a world map(gif) based on the longitude and latitude values obtained from database.

I know how to modify the image to plot the points on that. but for plotting the points need x,y cooridnates.
So need to convert the longitde/latitude values to x/y cartesian co-ordinates. Want to know the proper formula which will do this.

After getting the x,y cartesian coordinates how do i relate it to image's xy values. There seem to be some change in the scale of y values when moved from center to the pole because earth being spherical in shape.
All the above factors is confusing me how to go about it.

Can you throw some light on this.

thanks

mansoor

2. #### longitude/latitude to cartesian coordinates[ Go to top ]

Hi,
I am currently developing lat/lon translations for an online game that uses mercator maps that you can click on.
distances are calculated using rhumb lines and simple spherical trig functions.

contact me if you want more info tony dot saunders at cox dot co dot uk

3. #### longitude/latitude to cartesian coordinates[ Go to top ]

Wow, it's been a while since I messed with any of this stuff. For high-precision, you would have to already know what projection your gif image was using. If you use an equal-distance algorithm and try to plot on an equal-area map, you'll get inaccuracies that, as you note, will increase near the polar regions for cylindrical projections. Add to that the fact that there are a number of 'right-appearing' projections, it may be tough to infer the correct projection to use. Mercator is one of the most popular projections, although the last time I wrote a program to do this, I utilized the Robinson projection which is nice because it provides a set of tables that you can interpolate to get the x and y values. So, either find out what projection your map uses, or aggressively search for a gif in a well-known projection. The formulae are relatively easy to find for a particular projection.
For smaller-scale stuff, you might get away with straight conversions by mapping lat degrees to y values and long degrees to x values... for work that doesn't require high precision and only covers a small area (say a US state) below the 60 degree line, a straight conversion seems to work fine.
Caveat: All my work in this was a long time ago as a student. This opinion should not be confused with one from a qualified GIS professional.
4. #### longitude/latitude to cartesian coordinates[ Go to top ]

Most sailing charts are Mercator. What this means is that for the area on the chart, the north south distance has been exagerated so that 1 nautical mile on the east west is the same as one knot on the north south. 1 Knot = (check me on this) circumferance of the earth at the equator/60*360 or one minute. So for a mercator map, if you wanted to plot 30 degrees 2 minutes north, 50 degrees 32 minutes east, you would first find a mercator map that contained that area. Lets assume you find one that covers from 50 to 60 degrees east, and 30 to 40 degrees north, scanned as an image that is 100X100 cm (yes, huge, but it makes the math easy). The point would be x=32cm y=2 from the lower left.

Math was never my strong suit, so I am sure somewhere I switched a North and an X, but this should get across the genereal Idea.
5. #### longitude/latitude to cartesian coordinates[ Go to top ]

well how about the spatial coordinates way of doing things as in oracle 9i and with all its inbuilt functions?Any ideas on that.
6. #### longitude/latitude to cartesian coordinates[ Go to top ]

mansoor,

This problem you describe is non-trivial. My father is a professor of geography specializing in cartogtaphy and my training is in mathematics including specialization in geometries.

I assume you do not know the map projection used in your image. Even if you did know the projection to make use of the information you would have to have all of the parameters that go into it in order to map your lat/lon points to x/y.

There is a mechanism called "rubbersheeting" whereby you take the x/y coordinates of several identifiable points on your map (like the Florida Keys or the mouth of the Mississippi). You then mathematically derive a formula to transform these x/y points to the well-known lat/longs. This gives you a rough formula to do the conversion - a short cut to the projection.

The reference I use for this stuff is: "Map Projections-A Working Manual" by John Snyder. This book is a guide to map projections and the underlying mathematics. It was published by the USGS and may be out of print.

A google search for "rubber sheet cartography" yields several possible results.

Good luck.

--Dave
7. #### longitude/latitude to cartesian coordinates[ Go to top ]

hi all,
thanks for all your valuable feedback
bye
mansoor