I got surprised when I tried to convert degree decimal coordinates into utm by using available library in anacondautm
.
my coordinates looks like:
JavaScript
x
18
18
1
lon = array([83.71666667, 83.7 , 83.6 , 83.65 , 83.6 ,
2
83.88333333, 83.56666667, 83.88333333, 83.96666667, 83.75 ,
3
83.7 , 83.1 , 83.21666667, 83.73333333, 83.65 ,
4
83.4 , 83.56666667, 84. , 83.78333333, 83.68333333,
5
83.6 , 83.48333333, 83.3 , 83.38333333, 83.61666667,
6
83.98333333, 83.43333333, 83.53333333, 84.05 , 84.21666667,
7
83.15 , 83.06666667, 83.26666667, 83.25 , 83.8 ,
8
84.9 , 84.36666667, 84. , 83.88333333, 84.61666667,
9
84.35 , 84.41666667, 84.61666667, 83.81666667, 84.11666667,
10
83.81666667, 83.8 , 84.1 , 84.23333333, 84.28333333,
11
83.96666667, 84.01666667, 83.8 , 84.61666667, 84.1 ,
12
83.76666667, 84.13333333, 83.75 , 83.78333333, 83.91666667,
13
85. , 84.28333333, 84.41666667, 84.53333333, 85.13333333,
14
85.05 , 85.01666667, 84.81666667, 84.98333333, 84.43333333,
15
85.38333333, 84.81666667, 85.01666667, 84.93333333, 85.25 ,
16
85.18333333, 85.31666667, 85.3 , 85.11666667, 85.41666667,
17
85.25 , 85.54722 ])
18
and lat values are:
JavaScript
1
18
18
1
lat = array([28.78333333, 28.75 , 28.26666667, 28.48333333, 28.63333333,
2
28.81666667, 28.35 , 29.05 , 29.18333333, 28.18333333,
3
28.21666667, 28.4 , 28.6 , 28.4 , 28.03333333,
4
28.38333333, 28.15 , 29.1 , 28.96666667, 28.9 ,
5
28.46666667, 28.38333333, 28.05 , 28.56666667, 28.13333333,
6
29.18333333, 27.95 , 27.86666667, 27.68333333, 27.68333333,
7
27.93333333, 27.55 , 28.01666667, 28.06666667, 27.86666667,
8
28.36666667, 28.28333333, 28.21666667, 28.1 , 28.06666667,
9
28.13333333, 27.93333333, 28. , 27.88333333, 28.11666667,
10
28.26666667, 28.3 , 28.03333333, 28.55 , 27.96666667,
11
28.26666667, 28.06666667, 28.38333333, 28.2 , 28.36666667,
12
27.98333333, 27.86666667, 28.26666667, 28.26666667, 28.08333333,
13
28.48333333, 28.76666667, 27.61666667, 27.58333333, 27.55 ,
14
27.41666667, 27.41666667, 27.55 , 27.43333333, 27.06666667,
15
28.28333333, 28.05 , 27.91666667, 27.86666667, 27.8 ,
16
27.71666667, 28.01666667, 28.1 , 28.01666667, 27.75 ,
17
27.75 , 28.20946 ])
18
when I made scatter plot it looks like normal:
After converting coordinates in to utm distribution of the points change completely and looks strange like in this figure:
the code that i used to conver is:
JavaScript
1
8
1
import utm
2
X = []
3
Y = []
4
for i in np.arange(len(lat)):
5
LAT,LON,Z,S = utm.from_latlon(lat[i],lon[i])
6
X = np.append(X,LON)
7
Y = np.append (Y,LAT)
8
as suggested in comments: I switch lon lat positn i.e,
plt.scatter (Y,X)
it gives:
Am I doing something wrong, or is this result correct?
Advertisement
Answer
The answer might be helpful for others so I have posted my solution. I found pyproj
works better then utm
. In pyproj we can specify utm zone.
import pyproj
from pyproj import Proj
JavaScript
1
4
1
myProj = Proj("+proj=utm +zone=45U, +north +ellps=WGS84 +datum=WGS84 +units=m +no_defs")
2
lon_,lat_ = myProj(lon, lat)
3
plt.scatter(lon_,lat_)
4
and the figure looks good!