python - 如何使用标准 WGS84 将纬度和经度转换为具有坐标中心的 X 和 Y?
问题描述
例如,我有一个坐标列表(纬度,经度):
Coords_of_points = [(57.769999999999996, 108.06),
(60.271336095306005, 119.70058684113518),
(55.44781555321857, 121.56598882454766),
(42.39597453807919, 141.90642068006264),
(47.416832694979675, 126.65598006176236)]
Center_of_coordinates = (48.528055555555554, 135.18805555555556)
为了从 计算点的 X 和 Y Center_of_coordinates
,我使用这个函数:
def transform(Coords_of_points, Center_of_coordinates):
for i in range(len(Coords_of_points)):
line = Coords_of_points[i]
rad = 6372795
lat_point = math.radians(line[0])
lon_point = math.radians(line[1])
lat_0 = math.radians(Center_of_coordinates[0])
lon_0 = math.radians(Center_of_coordinates[1])
cl1 = math.cos(lat_0)
cl2 = math.cos(lat_point)
sl1 = math.sin(lat_0)
sl2 = math.sin(lat_point)
delta = lon_point - lon_0
cdelta = math.cos(delta)
sdelta = math.sin(delta)
y = math.sqrt(math.pow(cl2 * sdelta, 2) + math.pow(cl1 * sl2 - sl1 * cl2 * cdelta, 2))
x = sl1 * sl2 + cl1 * cl2 * cdelta
ad = math.atan2(y, x)
dist = ad * rad
x = (cl1 * sl2) - (sl1 * cl2 * cdelta)
y = sdelta * cl2
z = math.degrees(math.atan(-y / x))
if (x < 0):
z = z + 180
z2 = (z + 180.) % 360. - 180
z2 = - math.radians(z2)
anglerad2 = z2 - ((2 * math.pi) * math.floor((z2 / (2 * math.pi))))
x = round(((math.sin(anglerad2) * dist) / 1000), 3)
y = round(((math.cos(anglerad2) * dist) / 1000), 3)
yield x,y
当点位于 附近时,此功能效果很好Center_of_coordinates
,但如果它们位于远离Center_of_coordinates
,X 和 Y 计算错误,我猜这是由于地球曲率而发生的。
所以,如果我有 Point (57.769999999999996, 108.06)
,它的 X 和 Y fromCenter_of_coordinates
将被计算为(-1577, 1326.651)
。正确答案应该是:(-1590, 1338.34)
。
有人知道如何修改或更改整个算法以使用 WGS84 获得正确的 X 和 Y 点吗?
解决方案
推荐阅读
- python-3.x - jupyter notebook 没有启动
- excel - 如何使一个单元格等于另一个单元格的前三行?
- typescript - 升级 NestJS 的清洁方法
- c - 不要在 C++ 2 中生成相同的随机数
- oracle - Oracle 9 数据库作为 SSRS 2017 版本 14.0 中的数据源
- c# - 通过在文本框中输入名称 C# 从 csv 文件中获取全部详细信息
- c++ - 如何在 PIMPL 惯用语后面的接口中隐藏包含自定义 typedef 的 API?
- reactjs - 如何使用 DataSearch 作为 Reactivesearch 的受控组件?
- android - Gson 在序列化时忽略枚举的自定义 @SerializedName 值
- javascript - 服务器端 python 返回一个 zip 文件以供下载