I need to convert Longitude and Latitude to Easting and Northing for locations in Australia, so our mapping engine can display them on a map. While the engine supports a single location using Latitude and Longitude, it requires eastings and northings if I want it to display more than one location at the same time.

I want to write a PHP script which can convert latitude to northing, and longitude to easting.

The script will be easy if I know the mathematical formula, I guess. Most of the places on the web that show the formula use complex looking squiggles and symbols, and I cant understand them, as i'm no mathemetician. Can anyone show me the equation to do this? I think it should be easy...

Something more readable and pragmatic from http://www.uwgb.edu/dutchs/UsefulData/UTMFormulas.HTM

Where you get as well the average radius of Earth for Australia, for instance.

You want UTM international system coordinates, the ones used by GPS for instance:

The problem is that Earth is neither completely spherical nor flat in term of altitude.

Therefore the formulas provided are really complex.

They provide some explanations about the UTM system http://www.uwgb.edu/dutchs/FieldMethods/UTMSystem.htm

where it is said that (among other things)

- start counting from zero at the equator (latitude) ; actually South pole is 0 up to 9999 for 1 km before equator, then zero again up to North pole

-1km (9999), and the North pole is 0 again :)

So you see that intrinsecally the Eearth NS is approximated to 20,000km (e.g. 40000km for the whole Earth)

- longitude: a bit more complex. The 360 degrees of longitude are divided into 60 zones of 6 degrees.

Each zone meridian (e.g. 3 degrees) is - it is a convention - 500km (500000m).

It starts from actually 180W (or -180E): divide by 6 and round up to upper number to get the Zone.

So the UTM coordinates you will get are basically (x,z Eastern, +/-y Northern) where y is from 0 to 9999km and x is >0 and <1000km, z being the zone from 1 to 60. To get the actual coordinates UTM like please look again this http://www.uwgb.edu/dutchs/UsefulData/UTMFormulas.HTM.

This system, for the longitudes has the advantage, to my mind, to reduce largely the aspherical problem of the Earth, since your first get a zone which depends upon the longitude in degrees itself (not dependant of altitude or irregularities of Earth) then we are in a square of a few hundreds of km. Error is minimal.

So to summarize you don't have to use the complex math formula:

1. for longitude: convert your longitude to start from 180W, e.g. Lg = Lg + 180. (West being negative) So you get a Lg >=0 and < 360.

Then divide by 6 and round up: e.g. 80W, would be 180-80 = 100.

100/6 = 16.67, round up : 17. You are in zone 17. 100 modulo 6 = 4. So you are on the right side of the meridian of the zone 17!

A degree is about 111km (40000/360), the center of the meridian is 3 degree, you have 4, you are 1 degree after the center of the zone ; so your coordinate in zone 17 should be 500+111 = 611. (I just checked against the calculator given below and it worked :)

2. for latitude it is simpler :) Given the Earth radius R =~ 6366 km

It should be something like for for

North: latitude * 2 * PI * R / 360.

South: - (90 - latitude) * 2 * PI * R / 360.

(latitude: North and South get 0 to 90 positive degrees in my formula) so that you get positive Northern or negative depending on N/S.

E.g. 47N => Northern 47 * 2 * PI * R / 360 = 5222 km

E.g. 31S => Northern -59 * 2 * PI * R / 360 = -6555 km

(the calculator below will give you a slight different result as it uses the math formula :)

So you get your (lat,long) = (31S, 80W) => UTM (Northern -6555, Eastern 611km zone 17)

You can check your guesses against this (choose International UTM) http://www.ngs.noaa.gov/cgi-bin/utm_getut.prl (in metres)

(enter for instance N171234.0000 for latitude north 17 degrees 12' 34" and W0811234 for west 081 degrees 12'34")

Last thing if you think about using formulas given in links: beware degrees are usually given in Radians !!

A more math-like formula: http://www.tandt.be/wis/WiS/eqn2tf.html