Turbo87 / utm

Bidirectional UTM-WGS84 converter for python
http://pypi.python.org/pypi/utm
MIT License
486 stars 101 forks source link

Include computation of scale factor (k) and convergence angle (γ) #90

Open yongjun21 opened 2 years ago

yongjun21 commented 2 years ago

I used this library not for lat/lon to UTM x/y conversion but for deriving the transformation from UTM x/y offset to Web Mercator x/y offset from a ref point.

Current process involves

  1. converting 3 nearby points in UTM to lat/lon then
  2. calculating the Web Mercator meter offsets of the 3 transformed points then
  3. solving the linear equations to get the transformation that maps UTM offsets (from a ref point) to Web Mercator offsets
  4. the result is only an approximation since it relies on solving the transformation from the empirical values of 3 transformed points

After digging into the theory behind UTM, I realize this can be done more simply and accurately but computing the convergence angle and scale factor for the ref point: https://en.wikipedia.org/wiki/Transverse_Mercator_projection#convergence.

Like most other UTM libs, this does not include functions to compute k and γ but is probably not hard to extend since most of the logic for computing preliminary and intermediate values are already inside.

If maintainer is not able to commit time, I might be able to create a PR for this