# Difference between revisions of "Axis Order Confusion"

m (→The Solution) |
|||

Line 5: | Line 5: | ||

== Coordinate Systems == | == Coordinate Systems == | ||

− | From the perspective of a geographic software design three [http://en.wikipedia.org/wiki/Coordinate_system coordinate systems] can potentially be addressed: | + | From the perspective of a geographic software design three [http://en.wikipedia.org/wiki/Coordinate_system coordinate systems] can potentially be addressed. Each differ either in the order of the coordinate [http://en.wikipedia.org/wiki/Tuple tuple] or in the direction of increasing values. |

# Mathematical | # Mathematical | ||

− | #* Axis Order X, Y | + | #* Axis Order (X,Y) |

− | #* Signed values, increase | + | #* Signed values, increase to the right und upwards |

# Computer Graphics | # Computer Graphics | ||

− | #* Axis Order X, Y | + | #* Axis Order (X,Y) |

− | #* Unsigned values increase | + | #* Unsigned values increase to the bottom and to the right. The resutling graphics (often the screen or window size) size is a limit |

# Geographical Coordinate Systems | # Geographical Coordinate Systems | ||

− | #* Axis Order Y, X | + | #* Axis Order varies, sometimes (Y,X), othertimes (X,Y) |

#* Signed values increase up and right limited to -180, -90, 180, 90 (a shperoid) | #* Signed values increase up and right limited to -180, -90, 180, 90 (a shperoid) | ||

## Revision as of 05:21, 12 December 2006

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

## Contents

## 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.

- Mathematical
- Axis Order (X,Y)
- Signed values, increase to the right und upwards

- 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

- 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.

## 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 and say Latitude, Longitude (that is: y, x). 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.