I am trying to convert a set of local co ordinates into lat/long and vice versa and I have the code for it taken from this site itself , the issue is When I do these conversions they are not resulting the same.
converting local co ordinates to lat long:
import pyproj
import utm
x = -20509.2462745155
y = -125891.862952247
p = pyproj.Proj("+proj=tmerc +lat_0=34.863361375 +lon_0=138.273186441 +k_0=1.000008632 +a=6378137.0 +b=6356752.314200002 +x_0=-20737.317 +y_0=-126072.022 +units=m +no_defs")
lon, lat = p(x, y, inverse=True)
print(lat,lon) = 34.864985295652794 138.27568068953587
I also tried the inverse of the above code and it is not working as well.
lat =34.864985295652794
lon= 138.27568068953587
p = pyproj.Proj("+proj=tmerc +lat_0=34.863361375 +lon_0=138.273186441 +k_0=1.000008632 +a=6378137.0 +b=6356752.314200002 +x_0=-20737.317 +y_0=-126072.022 +units=m +no_defs")
nx,ny=p(lat,lon,inverse=True)
print(nx,ny) = 138.50356927081015 36.00068760121446
converting lat long into local coordinates using UTM package.
x, y, zone, ut = utm.from_latlon(34.864985295652794, 138.27568068953587)
print(x,y) = 250960.9300530484 3861456.658975485
as you can see the second piece of code is not exactly returning the X and Y values from the first code snippet.
I am not sure why this is happening , also I can notice that the first couple of values match. If this is not the proper way to perform this operation then , I would like to know how to approach this.
x, y = p(lat, lon)
?inverse=False