[postgis-users] lat,lon or lon,lat in WGS84 WKT

Andy Anderson aanderson at amherst.edu
Tue Nov 17 07:50:45 PST 2015


This OGC document:

        http://docs.opengeospatial.org/is/12-063r5/12-063r5.html#41

says:

7.5.5Axis order

Axis is repeated in a sequence. The number of axes in the sequence is the same as the dimensions of the coordinate system.

<axis order> identifies the order in which the coordinates of a point in a dataset are given and therefore is significant. In this International Standard it is defined in the BNF as an optional attribute to allow backward compatibility with OGC 01-009, however it is recommended that it should be explicitly included in a CRS WKT string.

Requirement:The following constraints shall apply:
• For coordinate systems with more than one axis, either every axis description
 shall include an <order> or none of the axes descriptions shall include an <order>.
 If <order> is included a sequence value shall not be repeated.
• When <axis order> is present in the WKT string the <axis> descriptions shall be ordered
  according to the axis order sequence.
• If <axis order> is omitted from the WKT string the sequence of <axis> descriptions
  shall imply the order of the axes and of coordinates referenced to the CRS.

and gives these three examples of geographic coordinate systems, all of which place latitude before longitude:

   GEODCRS[“WGS 84”,
     DATUM[“World Geodetic System 1984”,
       ELLIPSOID[“WGS 84”,6378137,298.257223563,
         LENGTHUNIT[“metre”,1.0]]],
     CS[ellipsoidal,3],
       AXIS["(lat)“,north,ANGLEUNIT[”degree",0.0174532925199433]],
       AXIS["(lon)“,east,ANGLEUNIT[”degree",0.0174532925199433]],
       AXIS[“ellipsoidal height (h)”,up,LENGTHUNIT[“metre”,1.0]]]

    GEODCRS[“NAD83”,
     DATUM[“North American Datum 1983”,
       ELLIPSOID[“GRS 1980”,6378137,298.257222101,LENGTHUNIT[“metre”,1.0]]],
     CS[ellipsoidal,2],
       AXIS[“latitude”,north],
       AXIS[“longitude”,east],
       ANGLEUNIT[“degree”,0.017453292519943],
     ID[“EPSG”,4269],
     REMARK[“1986 realisation”]]

    GEODCRS[“NTF (Paris)”,
     DATUM[“Nouvelle Triangulation Francaise”,
       ELLIPSOID[“Clarke 1880 (IGN)”,6378249.2,293.4660213]],
     PRIMEM[“Paris”,2.5969213],
     CS[ellipsoidal,2],
       AXIS[“latitude”,north,ORDER[1]],
       AXIS[“longitude”,east,ORDER[2]],
       ANGLEUNIT[“grad”,0.015707963267949],
     REMARK[“Nouvelle Triangulation Française”]]

PostGIS should use this information to understand the data in your polygon representation. Is your polygon defined correctly given some particular GCS, or was it generated incorrectly and its too much trouble to regenerate it? In the latter case perhaps you could define your own GCS that simply reverses the order. In either case, apply ST_Transform?

http://postgis.net/docs/ST_Transform.html

— Andy

On Nov 17, 2015, at 10:09 AM, Willy-Bas Loos <willybas at gmail.com<mailto:willybas at gmail.com>> wrote:

Hi,

I have a couple of questions about the order of lattitude and longitude in WKT representations of geometries:

  1.  Is there an objective reference that states in what order WGS84 (geographic) coordinates should be represented in a WKT? Is it lon, lat (because of x,y) or lat,lon (because it's geodetic) ?
  2.  Does postgis use the correct representation?
  3.  Is there a way to switch lat and lon for a polygon when representing as WKT? All i think of is looping through all points, switching x and y and then returning astext(g)

Cheers,

--
Willy-Bas Loos
_______________________________________________
postgis-users mailing list
postgis-users at lists.osgeo.org<mailto:postgis-users at lists.osgeo.org>
http://lists.osgeo.org/mailman/listinfo/postgis-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20151117/320f9f55/attachment.html>


More information about the postgis-users mailing list