# Geographic Coordinate Systems

On many occasion I have been handed a file containing geographic coordinates (csv, txt, etc.) to convert to point geometry and view in a GIS and when I plot them they appear anywhere else besides where I expect they should be on the earth. The problem starts with the way the x,y coordinates are perceived. We usually say lat/long coordinates and automatically associate the latitude value with x and the longitude value with y, when in reality it is the other way around. Many GIS software systems ask you to associate a field with the x and y to import data correctly and then you have web mapping like the Google Maps JavaScript API that builds geometry from lat/long which is y,x. It can be a headache getting to grips with geographic coordinates so I hope that this post will go some way to clarifying things to make sure that you embed in your mind that longitude is the x value (think along the equator) and latitude is the y value (think along the prime meridian).

In a geographic coordinate system any location (point) on the earth’s surface can be defined using a set of just two coordinates, a longitude (x-axis) and a latitude (y-axis). Longitude and latitude are angles measured from the equatorial plane and the prime-meridian at the centre of the earth.

I’ll attempt to simplify this in 5 easy steps…

1. Let’s take a model of the earth with the equator and prime meridian defined. 2. Place a point on the surface of the earth and draw a line from the pole to the equator through the point. 3. Draw a line from the closest pole (relative to the point) to the centre of the earth. 4. The longitude coordinate measures the angle between a line drawn from the centre of the earth to the intersection of the prime meridian and the equator (green line) to a line drawn from the centre of the earth to the intersection of the line drawn from the pole, through the point, to the equator (red line). 5. The latitude coordinate measures the angle between the plane of the equator and a line drawn from the centre of the earth to the point (dashed line). Longitude and latitude coordinates are angles that are generally measured in degrees or radians, but any angular measurement can be used. Degrees, however, are the more commonly used measurement. Longitude values range between -180 degrees (west) and +180 degrees (east) from the prime meridian. Latitude values range between -90 degrees at the South Pole to +90 degrees at the North Pole from the equator. The two most common ways of expressing a geographic coordinate are in degrees-minutes-seconds (dms) and decimal-degrees (dd) formats.

In the dms system each degree is divided into 60 minutes and each minute is divided into 60 seconds. 53° 20’ 52” is an example of a coordinate, but this could be a longitude or a latitude. If we tag an E or W after, then we would know that it is a longitude e.g. 53° 20’ 52” W. Similarly if we tag an N or S after we would know that it is a latitude e.g. 53°20’52” S.

An example of two coordinates representing a location on the surface of the earth is
6° 15″ 34.92′ W 53° 20″ 52.08′ N, which is a point in Dublin, Ireland.

The dd system uses degrees and a decimal fraction of a degree.

An example of two coordinates representing a location on the surface of the earth is -6.2597, 53.3478, which is a point in Dublin, Ireland. So, minus 6.2597 degrees is to the west of the prime meridian and positive 53.3478 is north of the equator. I like to keep longitude as the first coordinate to represent the x value, but I am also aware that the majority use y,x. As such, when using geographic coordinates from a non-spatial file format, it is important to investigate which are the x (long) and y (lat) values especially in cases where header/field information may be missing.

I hope that has gone some way to clarifying geographic coordinates. Check out the posts on using Python to convert decimal-degrees to degrees-minutes-seconds format and also using the Haversine formula to calculate the distance between two sets of coordinates on a sphere.

For further information on Spatial Reference Systems I highly recommend Chapter 1 of Alistair Aitchison’s book ‘Pro Spatial with SQL Server 2012’ published by Apress and available at http://www.apress.com/9781430234913.