【问题标题】:Convert x,y to latitiude and longitude将 x,y 转换为纬度和经度
【发布时间】:2020-09-02 04:53:23
【问题描述】:

如果我有一张地图图片在哪里:

  • 左上角的经纬度 (x=0, y=0) 已知
  • 图片的宽高已知
  • 缩放(z 轴)已知。

我们可以计算图像中其他坐标的纬度和经度吗? 例如,在下图中,如果我想计算白色多边形的纬度/经度值(坐标 (x,y) 已知)

【问题讨论】:

  • 我不确定你的意思,除了 0,0 你还有其他数据吗?你能提供一些背景吗?例如,如果你有一个多边形并且你找到了内部多边形,我可能会建议其他方法。
  • @yovelcohen 我有 4 个角的 lats 和 lons
  • 好的,所以你需要多边形的一个点才能到达其余点,或者需要边界中的一个点必须满足的条件,你明白我所说的条件吗?如果我知道最终目标,那么制定这样的条件会更容易
  • 我将计算像素大小为lat/image heightlong\image width,乘以坐标并减去已知点以创建参考框架。
  • 如果您能提供一些数字,可能会更容易显示。

标签: numpy geolocation latitude-longitude pyproj


【解决方案1】:

所以给定图像的信息和形状,(see previous question):

import numpy as np

top_left = np.array((32.0055597, 35.9265418))
bottom_right = np.array((33.0055597, 36.9265418))

delta = bottom_right - top_left

shape = (454, 394)[::-1] # convert from ij to xy coords

pixel_sizes = delta / shape

pixel_sizes * (80, 200) + top_left
>>> array([32.20860539, 36.36707043])

给出给定点的 (x, y) 或 (longtiude, latitude)。

这种方法可以使用 numpy 来概括给定一组点:

coords * pixel_sizes + top_left # coords is (N, 2) array

如果coords 是数组元组,则可以使用np.column_stack 将其转换为(N,2) 数组。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-07
    • 1970-01-01
    • 2012-06-10
    相关资源
    最近更新 更多