我有地图窗口中心的纬度,经度和缩放比例。我有尺寸图窗口。我在窗口中的地图上也有特定事件的像素位置(墨镜投影-openstreetmap)。有人可以帮助我如何将这些像素位置转换为纬度和经度坐标,或者以后可以在其他地图上可视化的任何其他坐标系吗?
答案 0 :(得分:0)
我已经找到使用该公式(https://en.wikipedia.org/wiki/Web_Mercator_projection)的解决方案 enter image description here
计算中心点的x,y位置
将窗口的坐标系转换为全局坐标
逆变换
def LatLontoXY(lat_center,lon_center,zoom):
C =(256/(2*pi) )* 2**zoom
x=C*(math.radians(lon_center)+pi)
y=C*(pi-math.log( math.tan( (pi/4) + math.radians(lat_center)/2 ) ))
return x,y
def xy2LatLon(lat_center,lon_center,zoom,width_internal,height_internal,pxX_internal,pxY_internal):
xcenter,ycenter=LatLontoXY(lat_center,lon_center,zoom)
xPoint=xcenter- (width_internal/2-pxX_internal)
ypoint=ycenter -(height_internal/2-pxY_internal)
C = (256 / (2 * pi)) * 2 ** zoom
M = (xPoint/C)-pi
N =-(ypoint/C) + pi
lon_Point =math.degrees(M)
lat_Point =math.degrees( (math.atan( math.e**N)-(pi/4))*2 )
return lat_Point,lon_Point