Closed automataIA closed 1 year ago
Return is always in Web Mercator, which is expressed in metres, not in lon/lat as the underlying tiles are always on that projection. Does that make sense?
From the documentation:
Closing as I think this is answered, but happy to engage further if there's any additional question.
For other people:
import pyproj
def web_mercator_to_lonlat(x, y):
# Define the Web Mercator and WGS 84 (longitude/latitude) projections
web_mercator = pyproj.Proj(proj='utm', zone=33, datum='WGS84')
wgs84 = pyproj.Proj(proj='longlat', datum='WGS84')
# Convert the Web Mercator coordinates to longitude/latitude
lon, lat = pyproj.transform(web_mercator, wgs84, x, y)
return lon, lat
def lonlat_to_web_mercator(lon, lat):
# Define the Web Mercator and WGS 84 (longitude/latitude) projections
web_mercator = pyproj.Proj(proj='utm', zone=33, datum='WGS84')
wgs84 = pyproj.Proj(proj='longlat', datum='WGS84')
# Convert the longitude/latitude coordinates to Web Mercator
x, y = pyproj.transform(wgs84, web_mercator, lon, lat)
return x, y
I write this code:
and the output is:
(13516512.585724287, 13540972.434775542, 2856910.369186746, 2876478.248427753)
But the coordinate for example are, circa: (25.014 , 121.473)
Why?