0

Is there any reason why QGIS swap axis order if CRS (EPSG:3908) is defined inside GML, for example:

<au:geometry>
    <gml:MultiSurface gml:id="_42d05737-123d-4a52-a655-aef968cd9511" srsName="urn:ogc:def:crs:EPSG:3908" srsDimension="2">
        <gml:surfaceMember>
            <gml:Polygon gml:id="_ae5f0b7e-2315-4567-95af-dc5ba90183dc">
                <gml:exterior>
                    <gml:LinearRing>
                        <gml:posList>6614600.56 4825580.27 6614639.00 482571.91 6614785.47 4825616.26 6614600.56 4825580.27</gml:posList>
                    </gml:LinearRing>
                </gml:exterior>
            </gml:Polygon>
        </gml:surfaceMember>
    </gml:MultiSurface>
</au:geometry>

The representation of data, in this case, is not correct, because X and Y are swapped.

If I delete the srsName definition and manually choose CRS during import, the representation is correct, the same representation of data is returned by FME. GML file is produced using hale studio from data stored in PostGIS database. I am using QGIS 3.0.2.

  • If you look at opengis.net/def/crs/EPSG/0/3908 your coordinate system is defined as Cartesian 2D CS. Axes: northing, easting (X,Y). Orientations: north, east. UoM: m. What QGIS does for your data? Does it show coordinates "6614600.56 4825580.27" as easting-northing even they are really northing-easting? – user30184 Sep 18 '18 at 4:14
  • My coordinates are easting, northing. This is test data drawn over OpenStreetMap loaded in projection 3908 in QGIS, so I trusted it, didn't check after. If CRS is defined in GML file it shows coordinates "4825580.27 6614600.56", but if I remove the definition of CRS for all geometry and manually choose that projection is EPSG:3908 during import of file it shows coordinates as "6614600.56 4825580.27". It seems that the problem is the definition of CRS used by QGIS, by definition false easting is 6 500 000, and if the Y represents easting it should be +y_0=6500000, not +x_0=6500000. – Zoran Kokeza Sep 19 '18 at 0:20
  • CRS definition is right because for Proj4 "x" means always easting and "y" means always northing. Could you tell where the point should be in explicit Latitude-Longitude coordinates. Write it as Lat= Lon= so there is no place for misunderstanding. – user30184 Sep 19 '18 at 13:45
  • Lon = 19°25', and Lat = 43°34', near the border of Serbia and Bosnia and Herzegovina – Zoran Kokeza Sep 20 '18 at 0:03
2

Axis order in coordinate systems and in GML is a complicated thing. The issue is all too complicated to be handled as a gis.stacexchange answer but I recommend to start by reading this https://wiki.osgeo.org/wiki/Axis_Order_Confusion and also the relevant parts of GDAL GML manual page https://www.gdal.org/drv_gml.html.

It is a bit difficult to find information about EPSG:3908 because it seems to be just deprecated in EPSG database version 9.5 with release notes "Significant revision to data for Canada and former Yugoslavia (Boznia and Herzegovina, Croatia, FYR Macedonia, Montenegro, Serbia, Slovenia)." Probably because of that I can't find a projected coordinate system with that code from the EPSG site http://epsg-registry.org/.

However, if we trust the info from http://www.opengis.net/def/crs/EPSG/0/3908 it feels certain that if you have a point at Lon = 19°25', and Lat = 43°34' and you want to express it as GML3 by giving the srsName reference as srsName="urn:ogc:def:crs:EPSG:3908" you must follow the official axis order which is northing-easting. Thus valid GML must look like

<gml:Point srsName="urn:ogc:def:crs:EPSG::3908"><gml:pos>4825580.27 6614600.56</gml:pos></gml:Point>

QGIS handles coordinater internally in easting-northing of longitude-latitude order and flips the coordinates. That's right and your original GML data is wrong.

If you remove the srsName definition then QGIS (or GDAL behind it) considers that axis order is the common GIS order easting-northing. Therefore it does not flip the coordinates and the result satisfies you. I think that it is a usable workaround but you most give the CRS code manually for QGIS.

The long urn format "urn:ogc:def:crs:EPSG:3908" was introdoced with GML3. Before that in GML2 a short format "EPSG:3908" was used and axis order was always easting-northing or longitude-latitude. For remaining some backwards compatibility GDAL continues to interpret the short CRS in a similar way also with GML3. So for GDAL this means the same point as before

<gml:Point srsName="EPSG:3908"><gml:pos>6614600.56 4825580.27</gml:pos></gml:Point>

You have a few options:

  • Keep the urn-format for CRS and flip the coordinates in GML for making it valid.
  • Keep the coordinate order but use short format "EPSG:3908" for srsName. QGIS should then open the data without flipping the coordinates (not tested).
  • Convert data with ogr2ogr and fix the axis order with the options provided by the GML driver https://www.gdal.org/drv_gml.html and open the converted data into QGIS.
  • The best option would be to configure Hale studio to produce valid GML but I do not know if it is possible.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.