问题描述
我正在创建一个程序,它在给定的地图上按纬度和经度查找城市 这是地图:Kazakhstan map,2312 x 1331
我已经使用了墨卡托公式,但是它只向我显示了这张地图上城市的位置:World map,当我尝试使用哈萨克斯坦地图时,它显示了错误的位置
import eel
import cv2
import math
import numpy as np
# Find IMAGE width and length to ues in function
img = cv2.imread('web/map.jpg')
height,width,channel = img.shape
print(img.shape)
#Almaty city lat 43.2500,lng 76.9000
#Nur-Sultan city lat 51.169392,lng 71.449074
def map_pixels(lat,lng):
FE = 180
radius = width / (2 * math.pi)
laTrad = lat * math.pi / 180
lngRad = (lng + FE) * math.pi / 180
x = (lngRad * radius)
yFromEquator = radius * math.log(math.tan(math.pi / 4 + laTrad /2))
y = (height / 2 - yFromEquator)
print(x,y)
return x,y
x,y = map_pixels(51.169392,71.449074)
# Drawing CIRCLES on the MAP
def drawing(x,y):
cv2.circle(img,(x,y),10,(0,255),cv2.FILLED)
cv2.imshow('Map with dots',img)
cv2.waitKey(0)
drawing(int(x),int(y))
我输入的经纬度只为世界地图找到正确的坐标,但是当我试图找到哈萨克斯坦的地图时,它显示了错误的数据。我已经意识到这两张卡是不同的,但是我该如何更改公式或代码以便正确显示所有内容
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)