小编tmw*_*n26的帖子

如何使用 Python 底图更快地绘制地理定位的 RGB 数据

我在使用带有纬度和经度数据的 Python 底图模块绘制 RGB 图像时遇到问题。现在,我可以制作我想要的绘图,但问题是它有多慢,因为它能够比 RGB 数据更快地绘制单通道数据,并且一般来说,单独绘制 RGB 图像也是如此快速地。由于我有纬度/经度数据,这就是事情变得复杂的地方。我已经检查了这个问题的解决方案:

如何使用 python 和底图绘制不规则间隔的 RGB 图像?

这就是我如何到达现在的位置。它本质上归结为以下问题。当在底图中使用该pcolormesh方法时,要绘制 RGB 数据,您必须定义一个 colorTuple 参数,它将逐点映射 RGB 数据。由于数组大小约为 2000x1000,因此这需要一些时间才能完成。下面是我正在谈论的内容的片段(完整的工作代码在下面):

if one_channel:
    m.pcolormesh(lons, lats, img[:,:,0], latlon=True)
else:
    # This is the part that is slow, but I don't know how to
    # accurately plot the data otherwise.

    mesh_rgb = img[:, :-1, :]
    colorTuple = mesh_rgb.reshape((mesh_rgb.shape[0] * mesh_rgb.shape[1]), 3)

    # What you put in for the image doesn't matter because of the color mapping
    m.pcolormesh(lons, lats, img[:,:,0], …
Run Code Online (Sandbox Code Playgroud)

python rgb geolocation matplotlib-basemap

5
推荐指数
1
解决办法
1755
查看次数

标签 统计

geolocation ×1

matplotlib-basemap ×1

python ×1

rgb ×1