小编nia*_*iaR的帖子

像素/阵列位置到纬度长 gdal Python

我正在尝试将表示 .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))
Run Code Online (Sandbox Code Playgroud)

python pixel raster gdal coordinates

5
推荐指数
2
解决办法
3152
查看次数

标签 统计

coordinates ×1

gdal ×1

pixel ×1

python ×1

raster ×1