spherely icon indicating copy to clipboard operation
spherely copied to clipboard

Usage of lat/lng vs lng/lat in constructors

Open jorisvandenbossche opened this issue 1 year ago • 3 comments

At the moment, the constructors use the lat/lng order convention from s2:

>>> spherely.Point(50, 4)
POINT (4 50)

But then, as you can see above, the WKT repr uses lng/lat, because that is (AFAIK) generally how WKT (or WKB) is expected to be expressed.

However, that is quite confusing, because that means you can't just copy the coordinates from some WKT string to the constructor ..

I was checking with R's s2 how they do that, but I don't directly see such explicit constructors from coordinates for a geography object. They do have an explicit s2_lnglat to create a S2LatLng object, and indeed they also use lng/lat order there, but because of the name of the function that is also directly clear.

jorisvandenbossche avatar Aug 30 '24 08:08 jorisvandenbossche

Ah, and I see there is also an explicit Point constructor https://r-spatial.github.io/s2/reference/s2_geog_point.html, which is also using lng/lat order.

jorisvandenbossche avatar Aug 30 '24 08:08 jorisvandenbossche

And bigquery seems to do the same: https://cloud.google.com/bigquery/docs/reference/standard-sql/geography_functions#st_geogpoint

jorisvandenbossche avatar Aug 30 '24 08:08 jorisvandenbossche

lng/lat order is now used in geometry creation functions added in #51.

benbovy avatar Oct 11 '24 14:10 benbovy