I am getting confused about how projections using pyproj.Proj are defined with respect to a point of tangency / lat lon origin.
Consider the following code:
import pyproj
p = pyproj.Proj('+proj=tmerc +lat_0=55 +lon_0=-1 +a=6378137 +b=6356752.3 +units=m +no_defs')
x, y = p(55, -1)
Now given that I specified the origin for latitude and longitude, I would expect that when specifying those coordinates I would be able to assert x == 0 and y == 0
, however I actually get (7571700.820174289, -6296411.725576388)
.
Can anyone explain why this is the case? My knowledge of projection/coordinate systems is limited, but I did my best to understand PROJ Cartographic help and a related wikibook page.
Many thanks in advance to any who can help set me straight and put me in the right direction :-)
Thanks to @lusitanica and their helpful answer, I have now tried setting the scale factor to 1 and rerunning:
x, y = pyproj.Proj('+proj=tmerc +lat_0=55 +lon_0=-1 +k_0=1 +a=6378137 +b=6356752.3 +units=m +no_defs', preserve_units=True)(55, -1)
Unfortunately this gives (7571700.820174289, -6296411.725576388)
as before, so the question is what other information is needed for the projection string?
Turns out I was being silly! pyproj.Proj
expects input in lon, lat order not lat, lon :-(
Thus the following works:
import pyproj
lat0, lon0 = 55, -1
p = pyproj.Proj(f'+proj=tmerc +lat_0={lat0} +lon_0={lon0} +a=6378137 +b=6356752.3 +units=m +no_defs')
x, y = p(lon0, lat0)
print(x, y) # 0.0, 0.0