MaxRev-Dev / gdal.netcore

GDAL 3.x C#/F# bindings for .NET apps
MIT License
162 stars 36 forks source link

Coordinate Transformation Issue #116

Closed rmaddu closed 11 months ago

rmaddu commented 11 months ago

Describe the bug We are using MaxRev.Gdal.Core TransformPoint method to transform the coordinates. When we compare the results with our internal Coordinate Transformation tool, we are seeing minor differences in transformed coordinates when we use the wkt or proj4. Below are the observations:

To Reproduce using MaxRev.Gdal.Core; using OSGeo.OSR; GdalBase.ConfigureAll(); Proj.Configure("runtimes/win-x64/native/maxrev.gdal.core.libshared"); //Copied the Grid shift files here (proj-data-1.16.zip) SpatialReference spatialSrc = new SpatialReference(string.Empty); SpatialReference spatialDest = new SpatialReference(string.Empty); spatialSrc.SetWellKnownGeogCS("EPSG:4326");

string wkt = "PROJCS[\"Equirectangular\",GEOGCS[\"GCS_NAD83\",DATUM[\"D_North_American_Datum_1983\",SPHEROID[\"GRS_1980\",6378137.0,298.257222101]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Equidistant_Cylindrical\"],PARAMETER[\"False_Easting\",0.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",0.0],PARAMETER[\"Standard_Parallel_1\",0.0],UNIT[\"Foot (International)\",0.3048]]"; spatialDest.ImportFromWkt(ref wkt); double[] resultedPoint = new double[3]; CoordinateTransformation transformator = new CoordinateTransformation(spatialSrc, spatialDest); transformator.TransformPoint(resultedPoint, 2.52405039918038, 4.22238145723863, 0);

Expected behavior Output from MaxRev.Gdal.Core TransformPoint:[1542104.1789854481, 921837.28731403814, 0] Output from our Internal Tool: [1540380.3333543336, 920806.8088579002, 0]

Environment information:

MaxRev-Dev commented 11 months ago

Your output is in XY meters. That doesn't correspond to projection units, which are in degrees. Which specific projection are you using? What EPSG code?

A quick comparison using QGIS and epsg.io tells me that there's no issue.

For me, WGS84 (EPSG:4326) to NAD83 (EPSG:4269) differs only at 7 digits compared to epsg.io.

image

Output of the console app is at the bottom:

image

rmaddu commented 11 months ago

No EPSG code for target. It's a custom CRS. When we use the above mentioned code, observed minor differences in transformed coordinates. We have used the grid shift files also but no luck. Below is the proj4 format - proj4: "+proj=eqc + lat_ts = 0 + lat_0 = 0 + lon_0 = 0 + x_0 = 0 + y_0 = 0 + datum = NAD83 + units = ft + no_defs"

MaxRev-Dev commented 11 months ago

@rmaddu I don't see any issues with packages. See the QGIS screenshot. I copied your projection string. The output is the same as mine.

MaxRev-Dev commented 11 months ago

Here's a QGIS output (with GDAL/PROJ (3.5.1/9.1.0) under the hood). It's the same as from packages. image