I am using Lat, Lon data and would like to average all the sample_data within a grid cell (say 1km x 1km) uniformly across the whole area, and then plot it similar to this post, but with a basemap, I'm a bit stuck where to start: Heatmap with text in each cell with matplotlib's pyplot
The code below plots values through each time point, and I'd like to average the data within defined grid squares across the whole data area at each time point, and plot the average value onto the basemap with a grid at set time intervals (ie. make a set of images for a timelapse/movie).
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
from netCDF4 import Dataset
import matplotlib.cm as cm
data = Dataset(netcdf_data,'r')
lat = data.variables['lat'][:]
lon = data.variables['lon'][:]
time = data.variables['time'][:]
fig = plt.figure(figsize=(1800,1200))
m = Basemap(projection='ortho',lon_0=5,lat_0=35,resolution='l')
m.drawcoastlines()
for value in range(0,len(sample_data)):
m.plot(lat[:,value], lon[:,value], alpha=1, latlon=True)
plt.show()