任何點我有一個數組anomalies_ind
這是以這種方式創建:散點圖不上繪製底圖
data_path = r"C:\Users\matth\Downloads\TRMM_3B42RT\3B42RT_Daily.201001.7.nc4"
f = Dataset(data_path)
latbounds = [ -45 , -10 ]
lonbounds = [ 105, 160 ]
lats = f.variables['lat'][:]
lons = f.variables['lon'][:]
# latitude lower and upper index
latli = np.argmin(np.abs(lats - latbounds[0]))
latui = np.argmin(np.abs(lats - latbounds[1]))
# longitude lower and upper index
lonli = np.argmin(np.abs(lons - lonbounds[0]))
lonui = np.argmin(np.abs(lons - lonbounds[1]))
precip_subset = f.variables['precipitation'][ : , lonli:lonui , latli:latui ]
data_low_indices1 = np.where((precip_subset > 0) & (precip_subset < 1))
data_low_indices2 = np.array(np.where((precip_subset > 0) & (precip_subset < 1))).T
anomalies_ind = []
for ind in data_low_indices2:
anomalies_ind.append(ind)
print(np.asarray(anomalies_ind))
這樣做的輸出是這樣的:
[[1, 23, 45]
[3, 45, 56]
...
[31, 45, 89]]
第一元素表示天在1月份,第二和第三元素分別代表經度和緯度。我想在地圖上給出像這樣的經度和緯度積點:
foo = np.asarray(anomalies_ind)
longs = foo[:,1]
lat = foo[:,2]
m = Basemap(llcrnrlon=105.,llcrnrlat=-45,urcrnrlon=160,urcrnrlat=-10)
m.drawcoastlines()
m.fillcontinents(color = 'lightgray', zorder = 0)
m.scatter(longs, lat, marker = 'o', color = 'k', zorder=10)
plt.show()
然而,沒有點在地圖上。有誰知道什麼是錯的?
編輯:這裏是真正的foo
陣列」
[[ 0 0 0]
[ 0 0 16]
[ 0 0 17]
...,
[ 30 219 113]
[ 30 219 114]
[ 30 219 116]]
如果您不要填滿大陸,你能看到分散?如果你甚至不畫海岸線呢? – cphlewis
@cphlewis:我已經試過了。我認爲這個問題可能是'longs = foo [:,1]'和'lat = foo [:,2]' –