TIL: English and GEOS Reference Points Opposite of Each Other

This post is less a TIL and more of a I knew that and I don't want to forget it again and stems from a bugfix in Tanzawa.

In English when we refer to a geo-coordinate we usually say it in latitude, longitude order. The reason why we say coordinates in this order is we could measure latitude accurately (via astronomical measurements) before longitude. Frontend mapping libraries like leaflet.js keep this familiar ordering. i.e. plotting points on a map takes a latitude/longitude array and events have a latlng property for referencing points.

GEOS, the open source geometry library used in most GIS (include GeoDjango) applications doesn't think of points in those terms, but as a graph of x,y coordinates.Β  As such if you when you're working with data across these boundaries it's important to not mix up your ordering.

When instantiating a Point it's tempting to just pass in floats directly. But if you do that it's easy to mix up the ordering , so I've started make sure I always use the keyword argument name to reduce mistakes.

from django.contrib.gis.geos import Point

# Keep our familiar lat/lon ordering without messing up the data point.
point = Point(y=35.31593281000502, x=139.4700015160363)
Interactions
1