Latitude and longitude give every place an address, and the address depends on the datum. The Earth is an ellipsoid, the surface of the sea is the geoid, and GPS gives heights above the ellipsoid. The shortest way between two places is a great circle, found with the haversine formula.
about 30 min1 simulation2 practice questions
Lesson 1 of 3Show all lessonsHide
Try the code and the simulations beside the lesson.
An address on a curved Earth
Two phone apps give the position of the same temple. The coordinates differ in the fourth decimal place, and the dots on the map are 12m apart. Which one is right? To answer, we must ask what the numbers measure, and from what surface. This lesson gives the address system of the globe and its shape.
Latitude and longitude
Latitude, φ, is the angle between the vertical of a place and the plane of the equator. It is positive to the north and negative to the south, and it runs from −90∘ to +90∘. Longitude, λ, is the angle east of the prime meridian, the meridian of Greenwich. It runs from −180∘ to +180∘. West is negative.
Old maps write degrees, minutes and seconds. There are 60′ in 1∘ and 60′′ in 1′. For example, 28∘36′36′′ is 28.61∘, because 28+36/60+36/3600=28.61. Software uses the decimal form.
Watch the order. Spoken, we say latitude first. A GIS, and the GeoJSON file format, put longitude first, as (x,y). Swapping them puts Delhi in Antarctica.
Longitude is also time. The Earth turns 360∘ in 24h, so 15∘ is one hour and 1∘ is 4 minutes. The mean solar time of a place is ahead of Greenwich by λ/15 hours.
The shape of the Earth
A sphere of radius 6371km is good enough for many sums. The real Earth is flattened by its spin. Its best-fitting smooth surface is an ellipsoid, a sphere squashed along the axis. The one that GPS uses is WGS84:
Quantity
Value
Equatorial radius a
6378.137 km
Flattening f
1/298.257223563
Polar radius b=a(1−f)
6356.752 km
The polar radius is 21.4km shorter than the equatorial radius. That is a flattening of only 0.34%.
A datum fixes an ellipsoid to the Earth. WGS84 is a global datum, built for the whole Earth. Older national datums, fitted to one country, used other ellipsoids. A coordinate in one datum and a coordinate in another differ for the same spot, by tens to hundreds of metres. Mixing them is a common cause of a layer that sits in the wrong place. A map must say which datum its coordinates use. The code for WGS84 latitude and longitude is EPSG:4326.
Heights have their own trap. The geoid is the surface of the sea at rest, extended under the land. It is a bumpy surface that lies within about 100m of the ellipsoid. A GPS receiver gives the height h above the ellipsoid. A height above sea level, H, is measured from the geoid. They differ by the geoid height N at that place:
H=h−N
Distances on the globe
On a sphere of radius R, the arc between two latitudes that differ by 1∘ is 111.19km for R=6371km. A degree of longitude is shorter away from the equator: 111.19cosφkm. On the real ellipsoid a degree of latitude is 110.57km at the equator and 111.69km at the poles.
The shortest path between two places on a sphere is an arc of a great circle, a circle whose centre is the centre of the sphere. If the angle between the two directions from the centre is θ, the distance is d=Rθ. The haversine formula gives θ from the coordinates. Work out the two parts a and b first:
a=sin22φ2−φ1
b=cosφ1cosφ2sin22λ2−λ1
θ=2arcsina+b
The initial direction, the bearing clockwise from north, comes from the other formula in the program below. A route that holds the compass bearing steady is a rhumb line. It crosses every meridian at the same angle, and it is longer than the great circle, except along a meridian or the equator.
A chord, the straight line through the Earth between two places, is shorter again: 2Rsin(θ/2).
Worked example: Mumbai to Nairobi
Mumbai is at 19.08∘ N, 72.88∘ E. Nairobi is at 1.29∘ S, 36.82∘ E. Find the great-circle distance and the bearing at the start.
The differences.Δφ=−20.37∘ and Δλ=−36.06∘.
The haversine. The formula is h=a+b.
a=sin2(10.185∘) is 0.0313.
cos19.08∘ is 0.9451.
cos1.29∘ is 0.9997.
sin2(18.03∘) is 0.0958.
So b=0.9451×0.9997×0.0958 is 0.0905.
Then h=0.0313+0.0905, which is 0.1218.
The angle.θ=2arcsin0.1218=40.85∘.
The distance.d=6371km×0.7129rad=4542km.
The bearing. The formula gives 244.1∘, a little south of west.
Check. If a student treated degrees as equal lengths, she would get 20.372+36.062×111.19=4605km. That is 1.4% too long, and the error grows far from the equator.
Put the first place at Delhi and the second at Quito, in Ecuador. By how many percent does the degree rule miss? Now put both places on the equator. Does the rule work there?
Practise with new numbers
Try it in Python
The program finds the great-circle distance from Delhi to three other cities and the direction to set out in.
Common mistakes
Treating a degree of longitude as a fixed length. It shrinks with cosφ.
Reading h from a GPS as the height above sea level. It is above the ellipsoid. Subtract the geoid height N.
Mixing the order of latitude and longitude. A GIS wants longitude first.
Forgetting that West and South are negative. A positive longitude for Lima puts it in China.
Remember these
φ from −90∘ to 90∘, λ from −180∘ to 180∘. 15∘ of longitude is 1h.
Great circle: haversine, d=Rθ. One degree of latitude is about 111.2km, and of longitude 111.2cosφkm.
Check yourself
Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.
How long is one degree of longitude at latitude 60∘?
A GPS gives an ellipsoid height of 245m at a place where the geoid height is −31m. What is the height above sea level?
Why is a great circle shorter than the line of constant compass bearing between two places at the same latitude?
A coordinate pair from a GIS reads (77.2,28.6). Which is the longitude?
References
J. P. Snyder, Map Projections: A Working Manual (USGS Professional Paper 1395, 1987), Chapter 3 Map Projection Properties, and the formulas for the sphere.
P. A. Longley, M. F. Goodchild, D. J. Maguire and D. W. Rhind, Geographic Information Science and Systems (4th edition, Wiley, 2015), Chapter 4 Georeferencing.
Enroll free in GIS: Coordinates, Projections and Map Layers
Every lesson is open to read. Enrolling also lets you:
Mark lessons done and carry on where you stopped.
Take the tests of this lesson and its course.
Count the course towards the certificate for its chapter.