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

Numpy interface gives misleading results when data spans multiple zones #61

Open
jgodwin opened this issue Dec 4, 2020 · 1 comment

Comments

@jgodwin
Copy link

jgodwin commented Dec 4, 2020

It appears that the numpy interface returns all the data in the lat/long arrays in the same zone regardless of how many zones the data actually spans. For example, here are some lat/longs in Texas that span 6 zones. When you run each data point through utm.from_latlong individually you get the right UTM zones (6) with output as shown below:

  lat        long       northing                        easting          utmzone

31.536598 -103.669795 626277.957127 3.489840e+06 13R
33.044924 -102.473123 721477.858368 3.601393e+06 13S
30.427469 -96.538430 736424.325834 3.368727e+06 14R
33.349272 -100.655458 344773.270375 3.694674e+06 14S
31.276065 -95.483046 263604.667649 3.462858e+06 15R
32.061439 -95.761137 239325.564516 3.550582e+06 15S

To be clear, this result is from doing:

result = []
for lat,long in zip(df['lat'],df['long']):
   result.append(utm.from_latlong(lat,long))

If you instead put those lat/long pairs into numpy arrays and then feed them through utm.from_latlong all at once, they all get projected into a single utm zone, which appears to be the first one in the dataset:

(array([ 626277.95712696, 735961.8832752 , 1314026.08573693,904396.7559105 , 1407848.61383494, 1373735.1761227 ]), array([3489839.70071501, 3659105.6188487 , 3396735.53928308, 3698446.73936288, 3499566.456626 , 3584840.23674779]), 13, 'R')

result = utm.from_latlong(df['lat'].values,df['long'].values)

@sdhiscocks
Copy link
Contributor

I think the current behaviour is correct, as a typical use case would require all points in the same projection.

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