Convert Latitude & Longitude (Decimal) to Easting & Northing
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...
not sure of the formula myself either...(but it looks reasonably complex)...below is a link to web site that does the conversions...it even has an Excel speadsheet you can download that does the conversions using Redfearn's formulae.
Yes, there is alot of data there, but they still dont show me (at least not that I could see) a usable conversion equation that i could put in my script.
I think easting is meters east of 0deg at the equator, and northing is meters north of the equator (negative values for west and south, respectively) is that right?
I have thought of trying:
Distance around earth at equator is 40,075,160 meters.
So Easting for 180deg LONGITUDE must be half this, correct?
Distance around earth pole to pole is 40,008,000 meters.
So Northing for 90deg LATITUDE must be 1/4 of this, correct?
Would the formulae below work?
EASTING=LONGITUDEx(40075160/360)
NORTHING=LATITUDEx((40008000/4)/90)
I understand that this may not take altitude and imperfections in earth's shape into account, but would this work with any degree of accuracy?
My first map will only be displayed 600 pixels wide, so i cant be amazingly accurate anyway.
0
Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.
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 !!
It looks like all the info i need to complete my task is available to me now, through the very good post by Mercantilum. The links are also useful. Cheers guys.
Very well thankyou, Merc. Now we can plot multiple points using Lat & Long, so i dont need to use easting and northing anymore, greatly simplifying my script. I know that I would have been able to use multiple points by doing a easting and northing conversion though, thanks to the help I got in this thread.
It was great information you provided, the only reason I gave you a B was because I read the suggested scoring (this was my first time) and since I was hoping for someone to actually give me the required formula to convert to Easting and Northing (i hope that doesnt sound lazy), I was reserving a A for this only. I also appreciate your on-going interest. You are real asset to experts-exchange!
Funny I'm back to this thread searching for a data from my own answer :) Since I'm here, let me add that:
Considering the time to make this answer and its rareness (you can search google - and you probably did it :) it deserved an A.
You talk about a << real asset to experts-exchange >> but you don't contribute to encourage people keeping answering.
I think that is a fair comment Merc, you are right. I couldnt find the answer on Google, and this is not something I considered when grading your score.
Your answer came up with this result:
Mercantilum>>>"So you get your (lat,long) = (31S, 80W) => UTM (Northern -6555, Eastern 611km zone 17)"
When the answer i needed was:
Mercantilum>>>"So you get your (lat,long) = (31S, 80W) = -XXXXX mtrs Northing, -XXXXX mtrs Easting"
I can see how much effort you went to. It was an A grade effort, and had I kept the thread running longer I am sure you would have landed me on the correct calculation. Please understand that we never actually got to the correct answer, we only got part of the way there, I did the rest myself. This is why I originally went for a B. I got there in the end only because of your help though - so I agree I 'could' have given you an A, but I am not totally convinced I should have. Personally, your grade is not that important to me that I would stand back and insist it's a 'B' - it obviously is important to you - so I'd give you an 'A' no worries. I am dissapointed by this statement:
Mercantilum>>>"but you don't contribute to encourage people keeping answering"
Even though I'd like to, I cant change your grade, as far as I know. I'm sorry mate. I really do think you are an asset to experts exchange, and I hope you continue to be. I wouldnt take the time to write this post unless I sincerely meant it.
This is exactly what I think:
- yes I care about points but may times my answer was not accepted as the author chose the first or last one ... and I don't really care
- the think is sometimes I really want as a personnal challenge to provide an accurate answer - it was the case for this one
And when other people will look for a similar question - they will see a B and think, well it's not what i'm looking for :)
http://www.ga.gov.au/nmd/geodesy/datums/calcs.jsp#coords
hope it helps..