[英]why isnt my gridded data showing up on basemap?
I am trying to plot NASA GISS gridded temperature data but my maps keep showing up blank.我正在尝试 plot NASA GISS 网格化温度数据,但我的地图一直显示空白。 Below is my code:
下面是我的代码:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
import geopandas as gpd
import xarray as xr
ncin = xr.open_dataset('GriddedAir250.nc')
lons = ncin.variables['lon'][:]
lats = ncin.variables['lat'][:]
air = ncin.air
MeanTmax=air.mean(dim='time')
m=Basemap(projection='merc',
llcrnrlon= -123.416059,
llcrnrlat=18.954443,
urcrnrlon=-61.285950,
urcrnrlat= 47.536340,
resolution='i')
lon, lat = np.meshgrid(lons, lats)
xi, yi = m(lon, lat)
# Add Coastlines, States, and Country Boundaries
m.drawcoastlines()
m.drawstates()
m.drawcountries()
# Plot Data
cs = m.pcolor(xi,yi,np.squeeze(MeanTmax))
# Add Colorbar
cbar = m.colorbar(cs, location='bottom', pad="10%")
cbar.set_label('winter')
# Add Title
plt.title('DJF Maximum Temperature')
plt.show()
All I get is a blank map that looks like this.我得到的只是一个空白的 map,看起来像这样。 Why isn't the temperature data showing up?
为什么没有显示温度数据?
The longitude grid in the source data is from 0 to 360 rather than -180 to 180. Because of this, it's likely that you've filtered out all of the data in your basemap projection command.源数据中的经度网格是从 0 到 360,而不是 -180 到 180。因此,您可能已经过滤掉了底图投影命令中的所有数据。 I haven't tested because I don't have the deprecated basemap package.
我没有测试,因为我没有已弃用的底图 package。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.