0

I am trying to plot NASA GISS gridded temperature data but my maps keep showing up blank. 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. Why isn't the temperature data showing up? enter image description here

Megan Martin
  • 221
  • 1
  • 9

1 Answers1

0

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. I haven't tested because I don't have the deprecated basemap package.

Robert Davy
  • 866
  • 5
  • 13