【问题标题】:Plotting a geotiff in python with a quiver plot overlay在 python 中使用 quiver plot 覆盖绘制 geotiff
【发布时间】:2017-11-11 18:50:23
【问题描述】:

我请求了解在 geotiff 图像上叠加速度的颤动图。我一直在使用 gdal 来处理 geotiff,并使用 netcdf4 库来获取速度数据。

到目前为止,我已经使用 imshow() 绘制 geotiff,放大了我的研究区域。在范围参数中,x 和 y 是域的东向和北向的 numpy 数组。下面是我的代码,以及我的结果图。

# plot study area
fig, ax = plt.subplots(figsize=(8, 8))
fig = plt.imshow(data[:3,:,:].transpose((1, 2, 0)), extent =
        [x[1000],x[2000],y[750],y[2000]])

在模型域内,我将水流的速度幅度作为箭袋图,其中eenn 是东向和北向速度的坐标。速度和坐标数据是从 netCDF 文件中提取的。下面是箭袋代码,以及箭袋图的链接。

plt.figure(figsize=(12, 12))
plt.quiver(ee,nn,test_u,test_v, scale=75)
plt.show()

我想在我的 geotiff 中覆盖顶部的速度大小。下面是我尝试执行此操作的代码。我相信我的 imshow 人物单位和我的 quiver-plot 单位没有正确排列。

plt.figure(figsize=(12, 12))
plt.imshow(data[:3,750:2000,1000:2000].transpose((1, 2, 0)),
       extent = [x[1000],x[2000],y[750],y[2000]])
plt.quiver(ee,nn,test_u,test_v, scale=75)
plt.show()

感谢您提供有关如何通过此问题的任何提示。如何设置我的 imshow 单位以使像素与地理坐标匹配,以及如何使其与箭袋图的单位匹配。我对使用 python 和 numpy、gdal 和相关库有点陌生。谢谢。

【问题讨论】:

    标签: python matplotlib plot gdal netcdf


    【解决方案1】:

    您需要使用extent 并将其设置为您拥有的实际单位。在这里,您似乎只需将x 中的数据乘以 1000。

    extent = [x[1000]*1000,x[2000]*1000,y[750]*1000,y[2000]*1000]
    

    但是,只有您可以确定坐标eenn 与图像像素的关系。

    【讨论】:

      猜你喜欢
      • 2020-07-26
      • 1970-01-01
      • 1970-01-01
      • 2021-11-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-20
      • 2019-07-21
      相关资源
      最近更新 更多