insarlab / MintPy

Miami InSAR time-series software in Python
https://mintpy.readthedocs.io
Other
555 stars 244 forks source link

`lalo2yx` behaves incorrectly when set of lat/lons cross UTM zone boundary #1176

Closed forrestfwilliams closed 2 months ago

forrestfwilliams commented 2 months ago

Description of the problem

When using latlon2yx to convert a set lat/lon points to pixel coordinates when using a UTM-based dataset, latlon2yx calls latlon2utm. When latlon2utm performs its conversion, it always converts the lat/lon coordinate into the native UTM zone for that point. This is not the desired behavior in some cases, because UTM-based MintPy datasets are in a single UTM zone, even if they cross a UTM boundary.

Proposed Changes Where appropriate, invoke the force_zone_number/letter arguments of the utm package's from_latlon function to ensure coordinates are converted correctly.

yunjunz commented 2 months ago

Thank you @forrestfwilliams for pointing this out. Invoking the force_zone_number sounds good to me. However, we do not need the force_zone_letter argument, as it does not affect the converted UTM easting/northing values, right?

>>> import utm
>>> utm.from_latlon(-41, 109, force_zone_number=48)
(836444.5771074533, 5453531.346152594, 48, 'G')
>>> utm.from_latlon(41, 109, force_zone_number=48)
(836444.5771074533, 4546468.653847406, 48, 'T')
>>> utm.from_latlon(41, 109, force_zone_number=48, force_zone_letter='G')
(836444.5771074533, 4546468.653847406, 48, 'G')
>>> utm.from_latlon(41, 109, force_zone_number=48, force_zone_letter='T')
(836444.5771074533, 4546468.653847406, 48, 'T')
forrestfwilliams commented 2 months ago

Thanks for opening the PR @yunjunz! Yep I think you're right, we don't need to force the zone letter.