NordicGeodesy / NordicTransformations

PROJ init-files describing the nordic transformations
Creative Commons Attribution 4.0 International
10 stars 5 forks source link

Wrong results with the NKG transformation #9

Closed sonjalaht closed 5 years ago

sonjalaht commented 6 years ago

The newest version of NKG parameter file (from September) seems to give wrong results at least for the transfromation between the ITRF and the NKG common frame. It seems to be linked to the helmert transformation and its "convertion=position_vector" thing that has replaced "transpose" parameter.

Below a simple example from ITRF2008 to NKG:

echo 2632277.4911 1266957.2666 5651027.5299 | cct -t 2014.978 +proj=pipeline +step +init=NKG:ITRF2008 +inv

OUTPUT old version: 2632277.9801 1266956.9709 5651027.2366 2014.9780 OUTPUT new version: 2632277.0298 1266957.6113 5651027.5356 2014.9780

kbevers commented 6 years ago

Do you get correct results if you instead use "convention=coordinate_frame"? It is likely that we are using the wrong convention...

sonjalaht commented 6 years ago

No, the result was exactly the same if I used "coordinate_frame" instead of "position_vector".

kbevers commented 6 years ago

Aha, that is odd. Which version of PROJ are you using? You can run cct --version to check it

sonjalaht commented 6 years ago

cct: Rel. 5.0.1, April 1st, 2018

kbevers commented 6 years ago

Yup, there's your problem. The latest version is 5.2.0. Unfortunately we had to change the parameters for the Helmert operation with version 5.2.0. See https://github.com/OSGeo/proj.4/issues/1091 for the details. As a consequence I updated the files in this repository as well. I should probably add somewhere that this will always be in sync with the latest version of PROJ.

Anyway, I have two possible solutions for you:

  1. Update to PROJ 5.2.0 (this is preferred)
  2. Replace "convention=coordinate_frame" with "transpose" in your NKG-file.

Please try that and report back how it goes.

sonjalaht commented 6 years ago

Well, I updated the PROJ. Now the results agree in horizontal, but not yet in vertical. I got 9 cm difference for the transformation below.

echo 2632277.4911 1266957.2666 5651027.5299 | cct -t 2014.978 +proj=pipeline +step +init=NKG:ITRF2008 +inv

OUTPUT (NKG aprl2018, proj 5.0.1): 2632277.9801 1266956.9709 5651027.2366 2014.9780 OUTPUT (NKG sept2018, proj 5.2.0): 2632278.0170 1266956.9887 5651027.3163 2014.9780

kbevers commented 5 years ago

From the commit message:

The null grids were added to avoid crashes when trying to transform coordinates outside the deformation grids. This unfortunately made the deformation operation use the null grid instead of the actual deformation model grids. The bug that caused PROJ to crash has since been fixed and the null grids can be removed from the +xy_grids and +z_grids parameters.

This will be fixed in PROJ 6/proj-datumgrid-europe-1.2. The problem can be fixed in 5.2 by removing ,@null from all xy_grids and z_grids parameters in the NKG-file.

With my development version (soon to be PROJ 6RC1):

(base) C:\dev\proj\ninjabuild>bin\cct.exe --version
cct.exe: Rel. 6.0.0, March 1st, 2019

(base) C:\dev\proj\ninjabuild>echo 2632277.4911 1266957.2666 5651027.5299 | bin\cct.exe -t 2014.978 +proj=pipeline +step +init=NKG:ITRF2008 +inv
 2632277.9801   1266956.9709  5651027.2366     2014.9780

I have also confirmed for a few select coordinates that they agree within 0.1 mm with the material provided by Pasi Häkli. With this change I believe it is safe to use this in production again.