Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project suggested by Claude.ai in a response but resulted in ~ 150m offset due to incomplete solution #126

Open
ramonsmits opened this issue Jan 11, 2025 · 0 comments

Comments

@ramonsmits
Copy link

Never heard of this project but https://claude.ai/ used it in a response.

I have a data set of EPSG:28992 points. The reponse used ProjNet to convert these to WGS 84. It boils down to the following code:

var rdNew = csFactory.CreateFromWkt(
    "PROJCS[\"Amersfoort / RD New\",GEOGCS[\"Amersfoort\",DATUM[\"Amersfoort\",SPHEROID[\"Bessel 1841\",6377397.155,299.1528128,AUTHORITY[\"EPSG\",\"7004\"]],AUTHORITY[\"EPSG\",\"6289\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4289\"]],PROJECTION[\"Oblique_Stereographic\"],PARAMETER[\"latitude_of_origin\",52.15616055555555],PARAMETER[\"central_meridian\",5.38763888888889],PARAMETER[\"scale_factor\",0.9999079],PARAMETER[\"false_easting\",155000],PARAMETER[\"false_northing\",463000],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AUTHORITY[\"EPSG\",\"28992\"]]");

var wgs84 = csFactory.CreateFromWkt(
    "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]]");

var ctFactory = new CoordinateTransformationFactory();
_rdNewToWgs84 = ctFactory.CreateFromCoordinateSystems(rdNew, wgs84);

I don't know what is wrong with it but it cause the lat/lng coordinates to be roughly 150 meters offset.

Interestingly the solution assumed Postgis and manually modifying it to use ST_Transform(geom, 4326) resulted in correct lat/lng coordinates.

I asked it to reflect on what could be causing the offset and Claude.ai replied with:

PostGIS handles this correctly because it includes the proper transformation grid file (nl_nsgi_rdcorr2018.gsb) and datum shift parameters, while our ProjNet implementation was doing a simpler, less accurate transformation.

It provided a fix (modify the CoordinateTransformer to include these parameters) but stated:

However, even with these parameters, you might still see small differences compared to PostGIS because PostGIS uses a more sophisticated grid-based transformation that accounts for local variations in the datum shift across the Netherlands.

Sharing this here because this wasted several hours of diagnosing an incorrect AI response and I assumed that conversion to be correct because it was a package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant