这是一篇必应上找的手册上的文章,特此记录
参考链接:
原文
参考链接2
影像中的RPC信息
1、仿射变换矩阵转换
上面说的利用仿射转换矩阵进行转换,一些注意事项可以参考原文,复现代码
import rasterio
from rasterio import transform,Affine
def Demo1_Affine():
trans = Affine(300.0379266750948, 0.0, 101985.0, 0.0,-300.041782729805, 2826915.0)#这个测数据不是很懂,为啥通过这些数据就能简历下面的仿射关系
transformer = rasterio.transform.AffineTransformer(trans)
GeoPoint = transformer.xy(0, 0)
PixPoint = transformer.rowcol(102135.01896333754, 2826764.979108635)
print("GeoPoint:",GeoPoint)
print("PixPoint:",PixPoint)
Demo1_Affine()
2、使用控制点转换
import rasterio
from rasterio import transform,Affine
from rasterio.control import GroundControlPoint
def Demo2_GCP():
gcps = [GroundControlPoint(row=11521.5, col=0.5, x=-123.6185142817931, y=48.99561141948625, z=89.13533782958984,
id='217', info=''),
GroundControlPoint(row=11521.5, col=7448.5, x=-122.8802747777599, y=48.91210259315549, z=89.13533782958984,
id='234', info=''),
GroundControlPoint(row=0.5, col=0.5, x=-123.4809665720148, y=49.52809729106944, z=89.13533782958984, id='1',
info=''),
GroundControlPoint(row=0.5, col=7448.5, x=-122.7345733674704, y=49.44455878004666, z=89.13533782958984,
id='18', info='')]
transformer = rasterio.transform.GCPTransformer(gcps)
test= transformer.xy(0, 0)#输入像素位置,输出经纬度位置
test2= transformer.rowcol(-123.478928146887, 49.52808986989645)#输入经纬度位置,输出像素位置
print("test:",test)
print("test2:",test2)
Demo2_GCP()
3、使用RPC进行坐标点转换