Skip to main content Link Search Menu Expand Document (external link)

Coordinate Objects

A Coordinate object is the most basic geometric element, describing a point on the surface of the Earth. Most GeoDesk functions accept coordinate values as simple (x,y) tuples, but using Coordinate objects has two advantages: They are more compact, and they convert seamlessly between Mercator projection and longitude/latitude (whereas tuples must use Mercator-projected coordinate values).

Construct coordinates like this:

Coordinate(lon=12.42, lat=48.76)      # longitude & latitude (any order)
Coordinate(x=148176372, y=668142957)  # Mercator-projected x/y position
Coordinate(148176372, 668142957)      # (Mercator projection by default)

Coordinates are equal to a simple tuple that has the same Mercator-projected coordinates:

>>> Coordinate(lon=12.42, lat=48.76) == (148176372, 668142957)
True

Coordinate objects are hashable and therefore suitable as dictionary keys.

Properties

Coordinate.x

The Mercator-projected x-ordinate.

Coordinate.y

The Mercator-projected y-ordinate.

Coordinate.lon

The coordinate’s longitude.

Coordinate.lat

The coordinate’s latitude.