Axis Order Confusion

From OSGeo
Jump to navigation Jump to search

Be careful when talking about or calculating with or passing on coordinate tuples as they can be ordered either (x,y) or (y,x)!

Introduction

A lot of trouble has been caused by a deep misunderstanding between software developers and GIS users with respect to the order of the X and Y values in a coordinate tuple. Before you start to rant away that they (the respective others) are completely mad at not sticking to either convention A (x,y) or convention B (y,x) please consider this to be a fact. Then read on and find out how we deal with the problem. If you can add to the solution go hack the Wiki. Tank you.

Coordinate Systems

From the perspective of a geographic software design three coordinate systems can potentially be addressed. Each differ either in the order of the coordinate tuple or in the direction of increasing values.

  1. Mathematical
    • Axis Order (X,Y)
    • Signed values, increase to the right und upwards
  2. Computer Graphics
    • Axis Order (X,Y)
    • Unsigned values increase to the bottom and to the right. The resutling graphics (often the screen or window size) size is a limit
  3. Geographical Coordinate Systems
    • Axis Order varies, sometimes (Y,X), othertimes (X,Y)
    • Signed values increase up and right limited to -180, -90, 180, 90 (a shperoid)

All result in an ordered pair of numbers describing a position in space but there is some confusion as to the order.

History of Axis Orders

This is just a very short introduction to the origin of this cnofusion and does not intended to prove anything (for example which is "right". Forget that.).

Reading Direction

The common reading direction (beware - this is only yet another convention) is from the left to the right and from the top to the bottom. Take a non-western approach to reading and you might end up from right t left or from top to bottom in columns. There is no single correct definition!

Mathematical Definition

From Wikipedia: Cartesian coordinate system: In mathematics, the Cartesian coordinate system is used to uniquely determine each point in the plane through two numbers, usually called the x-coordinate and the y-coordinate of the point. To define the coordinates, two perpendicular directed lines (the x-axis or abscissa and the y-axis or ordinate), are specified, as well as the unit length, which is marked off on the two axes.

This definition extends the vague terms of the x- and y-axis with the definitions abscissa and ordinate. This helps to make sure that people what they are talking about.

Usage in Geodesy

From Wikipedia: Geodesy: It is geodetic practice — contrary to the mathematical convention — to let the x axis point to the North and the y axis to the East.

This definition extends the vague terms of the x- and y-axis with the definitions of North and East. This helps to make sure that people know what they are talking about.

Navigation

Nowadays we are used to have positions come out of GPS and other machines and have x and y displayed as if there was no difference. Especially in maritime navigation there has always been a very big difference between finding the position along the rotational axis of the earth and the latitude (distance from the equator). Although both depended on each other a complete different set of tools (hardware) had to be used to find the exact position. This has led to a special terminology and the use of the terms latitude and longitude. Probably due to the same error which is being discussued now Geodesy uses the x-axis as a measure to the north and the y-axis as a measure to the east (or west) of a prime meridian.

Developing Software that uses Coordinates

Shoftware developers should usually try to implement interfaces for users. Many of these users do not now that the standard convention is to put X in front and Y in the back in a coordinate tuple. They have learned to use different terms to describe the same thing, namely Latitude and Longitude. And they learned to do it the other way round and say Latitude, Longitude (that is: y, x). In Geodesy the definitions for x (north) and y (east) are also different so that we end up by saying (x,y) meaning (Latitude, Longitude) but meaning (y,x) in a mathematical sense. Are they crazy? No they are not, they are simply sticking to another convention.

This confusion also applies to Spherical Coordinates in mathematics which does not make things any easier but shows that we are not alone with our problems. Citing from that page:

Warning: The notation for spherical coordinates is not standard. Sometimes they are written in a different order and sometimes the letters phi and theta are interchanged. In short, be careful when using spherical coordinates. You cannot assume that when someone else uses notation that looks like the notation here it is being used the same way.

This should be our prime contribution to this issue. Help people work it out so that the result is correct.

Why Bother?

There are several reasons why it is necessary to bother. Most have been mentioned on a very long mailing list thread at the OGC regarding the use of latlon in standards specifications (I am ignorant of whether these lists are public). If you had to pick from two reasons why to use either (x,y) or (y,x) which would you choose?

A) Because it is a convention
B) Because human life depends on it

So lets forget about whether it hurts anybody to read lonlat instead of latlon in a specification (option A). They will have to put up with this.

But yes, there are large user groups who are accustomed to using the wrong (both from mathematical and computer technological view point) axis order of Y, X. Every user in a nautical, aerial and ground navigation environment is used to a different notation. Basically anybody working with machine interfaces to spatially enabled technology is in danger of commiting an axis order confusion. If you look at the hardware tools they usually very clearly depict the axis order through labels. If you take a GPS or a radar it always says Latitude and Longitude printed on them.

On the technical side people developing software naturally fall back to the X,Y axis order because 99.9% of all IT does it his way. People using other devices often naturally fall back to the (y, x) notation.

The Solution

It will not help to define new standards or deprecate old ones or fix a new definition as the involved standard are already given. The only possible cure for this disease is to make people know about it. No matter how far the tuple is pushed in either the software or the user direction at one point it will collide with reality, either in computer graphics (which additionally have their origin in the upper left) or on a ship which does navigate first by latitude and then by longitude.

Whatever you do be careful that you do it the "right" way and make your choice clearly visible.