Hi, a short update to my problem.
Setting AxisMappingStrategy to OAMS_TRADITIONAL_GIS_ORDER it seems to fix my problem. (GDAL 3.0.1) Transformation from 31466 to 3857 (and reverse) and 4326_3857 (and reverse) returns the same coordinates as FME. src.SetAxisMappingStrategy(AxisMappingStrategy.OAMS_TRADITIONAL_GIS_ORDER); dest.SetAxisMappingStrategy(AxisMappingStrategy.OAMS_TRADITIONAL_GIS_ORDER); Regards, Carsten Von: gdal-dev <[email protected]> Im Auftrag von Carsten Lockenkötter Gesendet: Mittwoch, 4. September 2019 18:46 An: [email protected] Betreff: Re: [gdal-dev] GDAL (.NET) coordinate transformation via BETA2007 I have updated my C# application to use the GDAL 3.0.1 binaries from GISInternals. Transform via EPSG: var src = new SpatialReference(""); var dest = new SpatialReference(""); string wkt = "POINT(2575957.917 5728085.530)"; var geom = Geometry.CreateFromWkt(wkt); src.ImportFromEPSG(31466); dest.ImportFromEPSG(3857); var transform = new CoordinateTransformation(src, dest); geom.Transform(transform); geom.ExportToWkt(out string outWKT); // "POINT (3993425.20096133 2326133.24005068)" --> completely wrong With CPL_DEBUG=ON and PROJ_DEBUG=5, I get following information about this transformation: [cid:[email protected]] Transform via proj4 string: src.ImportFromProj4(@"+proj=tmerc +lat_0=0 +lon_0=6 +k=1 +x_0=2500000 +y_0=0 +ellps=bessel +nadgrids={absolutePath}\BETA2007.gsb +units=m +no_defs +type=crs"); dest.ImportFromEPSG(3857); // "POINT (790104.712949148 6742818.48632016)" --> ok Transform via proj4 +init (deprecated) src.ImportFromProj4("+init=epsg:31466"); dest.ImportFromEPSG(3857); // "POINT (790104.712949148 6742818.48632016)" --> ok [cid:[email protected]] Via CMD: [cid:[email protected]] --> ok FME returns: (790104.7129438451,6742818.485878875) So transforming via EPSG (source and destination) is using a completely wrong transformation in .NET, right? But why? My preferred method to transform is only via EPSG. But what I have to do, that the SpatialReference objects get the right transformation? Regards, Carsten Von: Schmitz, Uwe <[email protected]<mailto:[email protected]>> Gesendet: Donnerstag, 29. August 2019 10:30 An: Carsten Lockenkötter <[email protected]<mailto:[email protected]>>; [email protected]<mailto:[email protected]> Betreff: AW: GDAL (.NET) coordinate transformation via BETA2007 Carsten, are you shure that the grid is used during transformation? I know nothing about the C# package, but in my own tests the “not-found” case was often the cause for wrong results. So I tend to almost always use an absolute path to the grid file. Due to historical reasons gdal silently ignores this error. Ah, and I see that I put an extra +wktext at the end of the arguments. Don’t know if it’s still necessary. Regards Uwe Von: gdal-dev [mailto:[email protected]] Im Auftrag von Carsten Lockenkötter Gesendet: Dienstag, 27. August 2019 14:24 An: [email protected]<mailto:[email protected]> Betreff: [gdal-dev] GDAL (.NET) coordinate transformation via BETA2007 Hello, because SQLServer can't transform geometries, i have developed a .NET library (C#) that transforms the geometries based on GDAL (NuGet Package GDAL.Native v2.4.2). In principle, this also works. If i transform from 31466 to 3857, i have an offset of about 1.5m because gdal transformed via Helmert, not via Beta2007. If i transform the same geometrie via proj4 string to use my Beta2007.gsb file, i get a completly wrong geometry. sample code to transform via epsg Example: var inputGeom = "POINT (2529815.8 5642182.4)"; GdalConfiguration.ConfigureOgr(); var source = new SpatialReference(""); var destination = new SpatialReference(""); source.ImportFromEPSG(31466); destination.ImportFromEPSG(3857); CoordinateTransformation transform = new CoordinateTransformation(source, destination); Geometry ogrGeom = Geometry.CreateFromWkt(inputGeom); ogrGeom.Transform(transform); ogrGeom.ExportToWkt(out string outGeom); return outGeom; value of outGeom: POINT (776704.423009968 6626706.00572367) if i transform the same geometrie via FME with the CsmapReprojector, i get this (correct) coordinates: (776702.2109972419,6626706.521023605) FME used the gridfile Beta2007, GDAL not. So i tried to transform my geometrie via proj4 string, where I have the possibility to specify the gridfile. My gridfile Beta2007.gsb is located here: {ProjectRoot}\bin\Debug\gdal\share\Beta2007.gsb Example: var inputGeom = "POINT (2529815.8 5642182.4)"; GdalConfiguration.ConfigureOgr(); var source = new SpatialReference(""); var destination = new SpatialReference(""); source.ImportFromProj4("+proj=tmerc +lat_0=0 +lon_0=6 +k=1 +x_0=2500000 +y_0=0 +ellps=bessel [email protected]<mailto:[email protected]>"); destination.ImportFromEPSG(3857); CoordinateTransformation transform = new CoordinateTransformation(source, destination); Geometry ogrGeom = Geometry.CreateFromWkt(inputGeom); ogrGeom.Transform(transform); ogrGeom.ExportToWkt(out string outGeom); return outGeom; value of outGeom: POINT (776787.364952423 6626930.71048604) What i need: Beta2007 Transformation via EPSG code, but i don't know, where i have to change it. (optional) if i can't change the transformation via EPSG code via Gridfile, i need to know the correct proj4 string for my transformation. Best regards, Carsten
_______________________________________________ gdal-dev mailing list [email protected] https://lists.osgeo.org/mailman/listinfo/gdal-dev
