我正在尝试将表示 .tif 的栅格中的位置转换为相应的全局坐标。将整个数组转换为 tif 并将其加载到 QGIS 一切都被很好地引用了,但是使用下面的单点计算方法会有一个轻微的偏移(在结果坐标中到东-东北-东....
raster.tif 使用 ETRS 89 UTM Zone 32N
有人有想法吗?
from osgeo import ogr, gdal, osr
import numpy as np
raster = gdal.Open("rasters/raster.tif")
raster_array = np.array(raster.ReadAsArray())
def pixel2coord(x, y):
xoff, a, b, yoff, d, e = raster.GetGeoTransform()
xp = a * x + b * y + xoff
yp = d * x + e * y + yoff
return(xp, yp)
print(pixel2cood(500,598))