Basemap 和 numpy 2D 数组

0 投票
1 回答
1757 浏览
提问于 2025-04-18 02:53

我有一些物理数据,存储在一个叫做numpy数组的格式里,这些数据表示电磁场的密度。我知道这个数据的四个角落的经纬度和每个像素的大小。我会把我的数据和Basemap图结合起来,方法是把经纬度转换成x和y坐标,一点一点地处理,但这样做太慢了,因为数组里有超过一万个点。 所以,有没有其他方法可以在Basemap上绘制我的数据呢?

1 个回答

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()

当然可以!请把你想要翻译的内容发给我,我会帮你把它变得更简单易懂。

撰写回答