3

I'm trying to transform coordinates from a modified EPSG:31255 CRS (false northing +y_0 = 0) to EPSG:31255 (false northing +y_0 = -5000000) and always get a wrong result using GDAL 3.0.4. The transformation should remove 5000000 in y, but reverses xy as well.

With GDAL 2.4.0 everything works as expected.

Custom EPSG: +proj=tmerc +lat_0=0 +lon_0=13.3333333333333 +k=1 +x_0=0 +y_0=0 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m +no_defs

EPSG 31255: +proj=tmerc +lat_0=0 +lon_0=13.3333333333333 +k=1 +x_0=0 +y_0=-5000000 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m +no_defs
from osgeo import osr,ogr
wkt = 'POLYGON((32611 5320163,32611 5337745,54270 5337745,54270 5320163,32611 5320163))'
srs = '+proj=tmerc +lat_0=0 +lon_0=13.3333333333333 +k=1 +x_0=0 +y_0=0 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m +no_defs'
trs = 31255

src = osr.SpatialReference()
src.ImportFromProj4(srs)
tgt = osr.SpatialReference()
tgt.ImportFromEPSG(trs)

transform = osr.CoordinateTransformation(src,tgt)
polygon = ogr.CreateGeometryFromWkt(wkt)
polygon.Transform(transform)
print(polygon.ExportToWkt())

Do I miss something here? Is there any Config Setting that prevents this behavior?

3

As you can see from the definition of EPSG:31255 http://www.epsg-registry.org/export.htm?wkt=urn:ogc:def:crs:EPSG::31255 the official axis order is northing-easting.

Read the migration guide https://github.com/OSGeo/gdal/blob/master/gdal/MIGRATION_GUIDE.TXT and try this:

 OSRImportFromEPSG() takes into account official axis order.
 Traditional GIS-friendly axis order can be restored with
 OGRSpatialReference::SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER);
1
  • 1
    Thanks a lot! ...very useful information. tgt.SetAxisMappingStrategy(osgeo.osr.OAMS_TRADITIONAL_GIS_ORDER) did the trick. – christoph Jun 15 '20 at 12:28

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.