将x,y转换为经纬度。

问题描述 投票:0回答:1

如果我有一张地图图像,其中。

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

我们可以计算图像中其他坐标的经纬度吗?例如,在下面的图像中,如果我想计算白色ploygon的纬度值(其中坐标(x,y)是已知的)。

enter image description here

numpy geolocation latitude-longitude pyproj
1个回答
0
投票

所以给定信息和图像的形状,(见前题):

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 是一个数组的元组,它可以被转换为一个 (N,2) 阵列,使用 np.column_stack.

© www.soinside.com 2019 - 2024. All rights reserved.