View Ticket
Not logged in
Ticket Hash: 96216ad92d29353a9988f3ba1f8ad6f4349760a6
Title: axis order is not respected when using transform
Status: Closed Type: Code_Defect
Severity: Severe Priority: Immediate
Subsystem: Resolution: Rejected
Last Modified: 2020-08-26 07:29:49
Version Found In: 5.0.0-RC1
User Comments:
anonymous added on 2020-08-19 09:44:22:
(This is the same issue as https://www.gaia-gis.it/fossil/spatialite-tools/tktview?name=3041a242d3 , at first I didn't notice there is a different ticket system per tool. Please ignore/close that other ticket.)

Spatialite 5.0.0-RC1 does not seem to respect axis order although it is supposed to be using PROJ 6 (or later), see details below.

To get the WKT of the coordinate reference systems:

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\OSGeo4W>chcp 65001
Active code page: 65001

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\OSGeo4W>projinfo -o WKT2:2019 --single-line EPSG:25832
WKT2:2019 string:
PROJCRS["ETRS89 / UTM zone 32N",BASEGEOGCRS["ETRS89",DATUM["European Terrestrial Reference System 1989",ELLIPSOID["GRS 1980",6378137,298.257222101,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],ID["EPSG",4258]],CONVERSION["UTM zone 32N",METHOD["Transverse Mercator",ID["EPSG",9807]],PARAMETER["Latitude of natural origin",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8801]],PARAMETER["Longitude of natural origin",9,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8802]],PARAMETER["Scale factor at natural origin",0.9996,SCALEUNIT["unity",1],ID["EPSG",8805]],PARAMETER["False easting",500000,LENGTHUNIT["metre",1],ID["EPSG",8806]],PARAMETER["False northing",0,LENGTHUNIT["metre",1],ID["EPSG",8807]]],CS[Cartesian,2],AXIS["(E)",east,ORDER[1],LENGTHUNIT["metre",1]],AXIS["(N)",north,ORDER[2],LENGTHUNIT["metre",1]],USAGE[SCOPE["unknown"],AREA["Europe - 6°E to 12°E and ETRS89 by country"],BBOX[38.76,6,83.92,12]],ID["EPSG",25832]]

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\OSGeo4W>projinfo -o WKT2:2019 --single-line EPSG:3044
WKT2:2019 string:
PROJCRS["ETRS89 / UTM zone 32N (N-E)",BASEGEOGCRS["ETRS89",DATUM["European Terrestrial Reference System 1989",ELLIPSOID["GRS 1980",6378137,298.257222101,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],ID["EPSG",4258]],CONVERSION["UTM zone 32N",METHOD["Transverse Mercator",ID["EPSG",9807]],PARAMETER["Latitude of natural origin",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8801]],PARAMETER["Longitude of natural origin",9,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8802]],PARAMETER["Scale factor at natural origin",0.9996,SCALEUNIT["unity",1],ID["EPSG",8805]],PARAMETER["False easting",500000,LENGTHUNIT["metre",1],ID["EPSG",8806]],PARAMETER["False northing",0,LENGTHUNIT["metre",1],ID["EPSG",8807]]],CS[Cartesian,2],AXIS["northing (N)",north,ORDER[1],LENGTHUNIT["metre",1]],AXIS["easting (E)",east,ORDER[2],LENGTHUNIT["metre",1]],USAGE[SCOPE["unknown"],AREA["Europe - 6°E to 12°E and ETRS89 by country"],BBOX[38.76,6,83.92,12]],ID["EPSG",3044]]

To get the transformation pipeline:

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\OSGeo4W>projinfo -o PROJ -s EPSG:25832 -t EPSG:3044
Candidate operations found: 1
-------------------------------------
Operation No. 1:

unknown id, Inverse of UTM zone 32N + UTM zone 32N, 0 m, World

PROJ string:
+proj=axisswap +order=2,1


SQL statements in file transform.sql:

select
AsEWKT(PointFromText('POINT(722125 6178892)', 25832)) as geometry_25832,
AsEWKT(Transform(PointFromText('POINT(722125 6178892)', 25832), 3044)) as geometry_3044_only_newSRID,
AsEWKT(Transform(PointFromText('POINT(722125 6178892)', 25832), 3044, null, 'EPSG:25832', 'EPSG:3044')) as geometry_3044_EPSG_codes,
AsEWKT(Transform(PointFromText('POINT(722125 6178892)', 25832), 3044, null, 'urn:ogc:def:crs:EPSG::25832', 'urn:ogc:def:crs:EPSG::3044')) as geometry_3044_EPSG_URNs,
AsEWKT(Transform(PointFromText('POINT(722125 6178892)', 25832), 3044, null, 'PROJCRS["ETRS89 / UTM zone 32N",BASEGEOGCRS["ETRS89",DATUM["European Terrestrial Reference System 1989",ELLIPSOID["GRS 1980",6378137,298.257222101,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],ID["EPSG",4258]],CONVERSION["UTM zone 32N",METHOD["Transverse Mercator",ID["EPSG",9807]],PARAMETER["Latitude of natural origin",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8801]],PARAMETER["Longitude of natural origin",9,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8802]],PARAMETER["Scale factor at natural origin",0.9996,SCALEUNIT["unity",1],ID["EPSG",8805]],PARAMETER["False easting",500000,LENGTHUNIT["metre",1],ID["EPSG",8806]],PARAMETER["False northing",0,LENGTHUNIT["metre",1],ID["EPSG",8807]]],CS[Cartesian,2],AXIS["(E)",east,ORDER[1],LENGTHUNIT["metre",1]],AXIS["(N)",north,ORDER[2],LENGTHUNIT["metre",1]],USAGE[SCOPE["unknown"],AREA["Europe - 6°E to 12°E and ETRS89 by country"],BBOX[38.76,6,83.92,12]],ID["EPSG",25832]]', 'PROJCRS["ETRS89 / UTM zone 32N (N-E)",BASEGEOGCRS["ETRS89",DATUM["European Terrestrial Reference System 1989",ELLIPSOID["GRS 1980",6378137,298.257222101,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],ID["EPSG",4258]],CONVERSION["UTM zone 32N",METHOD["Transverse Mercator",ID["EPSG",9807]],PARAMETER["Latitude of natural origin",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8801]],PARAMETER["Longitude of natural origin",9,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8802]],PARAMETER["Scale factor at natural origin",0.9996,SCALEUNIT["unity",1],ID["EPSG",8805]],PARAMETER["False easting",500000,LENGTHUNIT["metre",1],ID["EPSG",8806]],PARAMETER["False northing",0,LENGTHUNIT["metre",1],ID["EPSG",8807]]],CS[Cartesian,2],AXIS["northing (N)",north,ORDER[1],LENGTHUNIT["metre",1]],AXIS["easting (E)",east,ORDER[2],LENGTHUNIT["metre",1]],USAGE[SCOPE["unknown"],AREA["Europe - 6°E to 12°E and ETRS89 by country"],BBOX[38.76,6,83.92,12]],ID["EPSG",3044]]')) as geometry_3044_wkt2_2019,
AsEWKT(Transform(PointFromText('POINT(722125 6178892)', 25832), 3044, null, '+proj=axisswap +order=2,1', null)) as geometry_3044_Transformation_pipeline;

spatialite output:

C:\OtherPrograms\spatialite-cli-NG-RC1-win-amd64>spatialite
SpatiaLite version ..: 5.0.0-RC1        Supported Extensions:
        - 'VirtualShape'        [direct Shapefile access]
        - 'VirtualDbf'          [direct DBF access]
        - 'VirtualXL'           [direct XLS access]
        - 'VirtualText'         [direct CSV/TXT access]
        - 'VirtualNetwork'      [Dijkstra shortest path]
        - 'RTree'               [Spatial Index - R*Tree]
        - 'MbrCache'            [Spatial Index - MBR cache]
        - 'VirtualSpatialIndex' [R*Tree metahandler]
        - 'VirtualElementary'   [ElemGeoms metahandler]
        - 'VirtualKNN'  [K-Nearest Neighbors metahandler]
        - 'VirtualXPath'        [XML Path Language - XPath]
        - 'VirtualFDO'          [FDO-OGR interoperability]
        - 'VirtualGPKG' [OGC GeoPackage interoperability]
        - 'VirtualBBox'         [BoundingBox tables]
        - 'SpatiaLite'          [Spatial SQL - OGC]
PROJ version ........: Rel. 7.1.0, August 1st, 2020
GEOS version ........: 3.8.1-CAPI-1.13.3
RTTOPO version ......: 1.1.0
TARGET CPU ..........: x86_64-w64-mingw32
the SPATIAL_REF_SYS table already contains some row(s)
SQLite version ......: 3.32.3
Enter ".help" for instructions
SQLite version 3.32.3 2020-06-18 14:00:33
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
spatialite> .headers ON
spatialite> .mode line
spatialite> .read transform.sql "UTF-8"
                       geometry_25832 = SRID=25832;POINT(722125 6178891.999999999)
           geometry_3044_only_newSRID = SRID=3044;POINT(722125 6178891.999999999)
             geometry_3044_EPSG_codes = SRID=3044;POINT(722125 6178891.999999999)
              geometry_3044_EPSG_URNs = SRID=3044;POINT(722125 6178891.999999999)
              geometry_3044_wkt2_2019 = SRID=3044;POINT(722125 6178891.999999999)
geometry_3044_Transformation_pipeline = SRID=3044;POINT(6178891.999999999 722125)

Only when using the transformation pipeline, the correct result is obtained.


When using PROJ to transform the coordinates, I get the following output:

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\OSGeo4W>echo 722125 6178892 | cs2cs EPSG:25832 EPSG:3044
6178892.00      722125.00 0.00

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\OSGeo4W>echo 722125 6178892 | cs2cs urn:ogc:def:crs:EPSG::25832 urn:ogc:def:crs:EPSG::3044
6178892.00      722125.00 0.00

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\OSGeo4W>echo 722125 6178892 0 0 | cct +proj=axisswap +order=2,1
 6178892.0000    722125.0000        0.0000        0.0000

sandro added on 2020-08-26 07:29:49:
Sorry, changing the traditional and well established axis order will abruptly break any historical compatibility with existing databases created by earlier versions.
Absolutely out of discussion, it would disseminate chaos everywhere.