cds*_*ald 15 python gis numpy matplotlib coordinate-systems
我正在使用matplotlib.pyplot.scatter绘制一堆UTM坐标.我还有一张背景航空照片,我知道这个照片与图的确切程度相符.当我绘制数据并设置轴时,我可以正确显示散射.如果我使用imshow绘制航空照片,则使用像素数作为轴位置.我需要将图像(numpy数组)移动到它正确的UTM位置.有任何想法吗?我是matplotlib和numpy的新手.
例如:我知道图像的左上角(imshow坐标:0,0)具有UTM坐标(269658.4,538318.2).我怎么告诉imshow同样的事情?
我还应该说我调查了Basemap但它似乎还没有完全支持UTM.我的学习领域很小.
Joe*_*ton 22
您需要使用extent关键字参数进行imshow.
作为一个简单的例子:
import numpy as np
import matplotlib.pyplot as plt
# Random points between 50000 and 51000
x, y = 1000 * np.random.random((2, 10)) + 50000
# A 10x10 "image"...
image = np.arange(100).reshape((10,10))
# In a lot of cases, image data will be "flipped" vertically, so you may need
# use the `origin` kwarg, as well (or just swap the ymin and ymax ordering).
plt.imshow(image, extent=[x.min(), x.max(), y.min(), y.max()])
plt.plot(x, y, 'ro')
plt.show()
Run Code Online (Sandbox Code Playgroud)
