簡體   English   中英

底圖和numpy二維數組

[英]Basemap and numpy 2d array

我在柵格中有一些物理數據作為numpy數組(電磁場密度)。 我知道緯度,角落的經度和像素大小。 我知道如何通過逐點將坐標從lat,lon轉換為x,y來將柵格與底圖圖結合起來,但是這花費了太多時間,因為數組中的點數超過了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()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM