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

Inaccurate and asymmetric (North/South) transformation utm to lat lon #120

Open
camillechasset opened this issue Mar 18, 2024 · 2 comments

Comments

@camillechasset
Copy link

There is apparently an error (wrong parenthesis position) in the transformation from UTM to lat / lon, at this line:

latitude = (p_rad - (p_tan / r) *

Original computation:

    latitude = (p_rad - (p_tan / r) *
                (d2 / 2 -
                 d4 / 24 * (5 + 3 * p_tan2 + 10 * c - 4 * c2 - 9 * E_P2)) +
                 d6 / 720 * (61 + 90 * p_tan2 + 298 * c + 45 * p_tan4 - 252 * E_P2 - 3 * c2))

Proposed change:

    latitude = p_rad - (p_tan / r) *
                (d2 / 2 -
                 d4 / 24 * (5 + 3 * p_tan2 + 10 * c - 4 * c2 - 9 * E_P2) +
                 d6 / 720 * (61 + 90 * p_tan2 + 298 * c + 45 * p_tan4 - 252 * E_P2 - 3 * c2))

One simple thing to notice is that the original correction term in d6 had the same sign in the North and South hemisphere whereas it is expected to change.
I attach some plots showing the performance improvement when implementing this change, evaluated by doing the double conversion from utm to lat/lon and then back:

  • Residual errors excluding Norway exceptions, before fix (left) and after (right), error reduced from up to 4.5mm to 0.8mm (decreased by a factor ~6). Note the North / South asymmetry.
    latlonErrorNoExceptions
  • Same, including Norway exception. Error reduced from up to 6.5cm to 6.5mm (decreased by a factor ~10).
    latlonErrorNorway
  • Same, including Svalbard exception. Error reduced from up to 8cm to 13mm (decreased by a factor ~6).
    latlonErrrorSvalbard

I didn't manage to find the source of the code, but on this page you can see a similar series decomposition, and all terms of the latitude expression series are multiplied by beta1*t1, which in your code is (p_tan / r). That's why I believe the change is needed.

@camillechasset
Copy link
Author

There is apparently an error (wrong parenthesis position) in the transformation from UTM to lat / lon, at this line:

latitude = (p_rad - (p_tan / r) *

Original computation:

    latitude = (p_rad - (p_tan / r) *
                (d2 / 2 -
                 d4 / 24 * (5 + 3 * p_tan2 + 10 * c - 4 * c2 - 9 * E_P2)) +
                 d6 / 720 * (61 + 90 * p_tan2 + 298 * c + 45 * p_tan4 - 252 * E_P2 - 3 * c2))

Proposed change:

    latitude = p_rad - (p_tan / r) *
                (d2 / 2 -
                 d4 / 24 * (5 + 3 * p_tan2 + 10 * c - 4 * c2 - 9 * E_P2) +
                 d6 / 720 * (61 + 90 * p_tan2 + 298 * c + 45 * p_tan4 - 252 * E_P2 - 3 * c2))

One simple thing to notice is that the original correction term in d6 had the same sign in the North and South hemisphere whereas it is expected to change. I attach some plots showing the performance improvement when implementing this change, evaluated by doing the double conversion from utm to lat/lon and then back:

  • Residual errors excluding Norway exceptions, before fix (left) and after (right), error reduced from up to 4.5mm to 0.8mm (decreased by a factor ~6). Note the North / South asymmetry.
    latlonErrorNoExceptions
  • Same, including Norway exception. Error reduced from up to 6.5cm to 6.5mm (decreased by a factor ~10).
    latlonErrorNorway
  • Same, including Svalbard exception. Error reduced from up to 8cm to 13mm (decreased by a factor ~6).
    latlonErrrorSvalbard

I didn't manage to find the source of the code, but on this page you can see a similar series decomposition, and all terms of the latitude expression series are multiplied by beta1*t1, which in your code is (p_tan / r). That's why I believe the change is needed.

@Turbo87 any thoughts about this? 🙏

@tvkn
Copy link

tvkn commented Jun 17, 2024

Hey @Turbo87! Can we help by opening a PR to fix this?
Thanks!

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

2 participants