gdal geotiff 坐标计算

xiaoxiao2021-02-28  50

GDAL处理地理图像坐标计算

本文讲解如何使用GDAL处理地理图像时,通过使用行列号计算和转换成tiff图像的地理坐标:

tif中坐标计算的方法如下,其中Col表示该坐标点处图像的列号,ROW表示该坐标点处图像的行号, 比如图像左上角Col为0,ROW为0,图像右下角Col为图像宽度,ROW为图像高度。  Xgeo = GT(0) + Col*GT(1) + Row*GT(2)

 Ygeo = GT(3) + Col*GT(4) + Row*GT(5)

一、文中用到的系数说明:

Col表示该坐标点处图像的列号 ROW表示该坐标点处图像的行号 x:该点X坐标 y:该点Y坐标 upleft:图像左上角坐标 upright:图像右上角坐标 downleft:图像左下角坐标 downright:图像右下角坐标

二、公式推导

则根据计算公式: GT(0)=左上点的Xgeo=upleft(x) GT(3)=坐上点的Ygeo=upleft(y) upRighg(x)=GT(0)+srcWidth*GT(1)+0*GT(2) =>GT(1)=(upRight(x)-GT(0))/srcWidth; downLeft(x)=GT(0)+0*GT(1)+srcHeight*GT(2) =>GT(2)=(downLeft(x)-GT(0))/srcHeight upRight(y)=GT(3)+srcWidth*GT(4)+0*GT(5) =>GT(4)=(upRight(y)-GT(3))/srcWidth; downLeft(y)=GT(3)+0*GT(4)+srcHeight*GT(5) =>GT(5)=(downLeft(y)-GT(3))/srcHeight;

(三)系数验证

验证:右下角(假设图像为平行四边形) downright=[downleft(x)+(upright(x)-upleft(x)), upright(y)-(upleft(y)-downleft(y))]

(1)证明右下角X方向坐标成立:downright(x)=downleft(x)+(upright(x)-upleft(x)

downright(x)=GT(0) + Col*GT(1) + Row*GT(2) =upleft(x)+srcWidth*(upRight(x)-GT(0))/srcWidth+srcHeight*(downLeft(x)-GT(0))/srcHeight =upleft(x)+upRight(x)-GT(0)+downLeft(x)-GT(0) =upleft(x)+upRight(x)-upleft(x)+downLeft(x)-upleft(x) =upRight(x)+downLeft(x)-upLeft(x) 证明成立(系数GT(0),GT(1),GT(2)正确)

(2)证明右下角Y方向坐标成立:

downright(y)=upright(y)-upleft(y)+downLeft(y) downright(y)=GT(3) + Col*GT(4) + Row*GT(5) =upleft(y)+srcWidth*GT(4)+srcHeight*GT(5) =upleft(y)+srcWidht*(upRight(y)-GT(3))/srcWidth+srcHeight*(downLeft(y)-GT(3))/srcHeight =upleft(y)+upRight(y)-GT(3)+downLeft(y)-GT(3) =upleft(y)+upRight(y)-upleft(y)+downLeft(y)-upleft(y) =upRight(y)+downLeft(y)-upleft(y)

证明成立(系数GT(3),GT(4),GT(5)正确)

(四)结果图

转载请注明原文地址: https://www.6miu.com/read-73537.html

最新回复(0)