Search code examples
javascriptopenlayers

Why Openlayers switches lat,lon order for coordinates?


As a non GIS expert, I am, or rather was, aware of two different formats of GPS coordinates expressing the latitude and longitude of a position on Earth's surface. The first one uses degrees, minutes and seconds (kinda "imperial system style" if you like). The second one uses decimal degrees (kinda "metric system style" if you like).

As I'm reading up on WGS84, my belief that the Earth was flat... I mean a sphere, has been shattered. It's an ellipsoid. Not a sphere. You bunch of lying teachers! :-) Anyhow, I've come across a third format: the UTM coordinate system.

The GPS coordinates for the Big Ben in London are for example:

  1. degrees, minutes and decimal seconds: 51° 30' 2.624" N 0° 7' 28.65" W
  2. decimal degrees: 51.500729, -0.124625
  3. UTM: Zone 30U E: 699565.68 N: 5709430.72

Source: https://www.gps-latitude-longitude.com/gps-coordinates-of-london-big-ben

What's noticable about the UTM coordinates (format 3), is that latitude and longitude have been reversed compared to format 1 and 2 I'm more familiar with. So I wonder, is it because of UTM coordinates that OpenLayers uses "reverse" order for lat,lon coordinates (see https://openlayers.org/en/latest/apidoc/module-ol_coordinate.html)?

Afterthought: if OpenLayers has been developed to further the use of geographic information of all kinds, shouldn't this "anomaly" be fixed to make it more accessible for non-GIS experts?

EDIT: perhaps I should not have mentioned UTM here. Why does Openlayers expect coordinates in the order [lon, lat] and not the "usual" [lat, lon] order?

var coord = [7.85, 47.983333];
var out = toStringHDMS(coord);
// out is now '47° 58′ 60″ N 7° 50′ 60″ E'

Solution

  • According to ISO 6709, the correct order is [latitude, longitude].

    But many software products and standards require [lon, lat] order. It's not only OpenLayers but for example also PostGis, GeoJSON, KML and almost all professinal GIS applications.

    I can think of two reasons why computer scientists have defined it differently than geographers.

    • It is conventional math to write f(x,y), i.e. easting before northing.
    • The WMS specification 1.0 from 2000 indirectly defined the [lon, lat] order. Software products of that time have implemented this standard. Even if the standard was revised a short time later, the software products remained at [lon, lat] to avoid version problems.