【问题标题】:Basemap and numpy 2d array底图和 numpy 二维数组
【发布时间】:2014-05-03 16:19:47
【问题描述】:

我在栅格中有一些物理数据作为 numpy 数组(电磁场密度)。我知道它的角的纬度、经度和像素大小。我知道如何通过将坐标从 lat,lon 逐点转换为 x,y 来将我的栅格与 Basemap 绘图相结合,但是这需要太多时间,因为数组中有超过 10k 个点。 那么,还有其他方法可以在 Basemap 上绘制我的数据吗?

【问题讨论】:

    标签: python numpy matplotlib-basemap


    【解决方案1】:
    width = 200
    height = 300
    lllon, lllat, urlon, urlat = -144.99499512, -59.95500183, -65.03500366, 60.00500107
    dlon = (urlon-lllon) / width
    dLat = (urlat-lllat) / height
    baseArray = np.fromfunction(lambda y,x: (1000.0 / (width + height)) * (y+x), (height, width), dtype = float)
    lons = np.arange(lllon, urlon, dlon)
    lats = np.arange(lllat, urlat, dLat)
    lons, lats = np.meshgrid(lons, lats)
    
    fig = plt.figure()
    plt.title("The Plot")
    m = Basemap(projection='cyl',
              resolution = 'c',
              llcrnrlon = lllon, llcrnrlat = lllat,
              urcrnrlon =urlon, urcrnrlat = urlat
    )
    
    m.pcolormesh(lons, lats, baseArray, shading='flat', latlon=True)
    plt.show()
    

    【讨论】:

    • 我就是这样做的。创建颜色网格似乎很快,但显示速度非常慢。
    猜你喜欢
    • 2015-10-27
    • 2015-06-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-18
    • 2020-07-30
    • 2022-01-15
    相关资源
    最近更新 更多