Sample R code for reading EQUATES CMAQ output (netcdf files)

Attached is some sample R code for accessing the 2017 EQUATES CMAQ daily average output netcdf file located in this Google Drive folder. The script shows how to:

  • open the netcdf file
  • extract the variable names and units, as well as the date and model grid information
  • read in the daily average PM2.5 data and calculate the annual mean PM2.5 for each grid cell
  • plot the annual average PM2. 5 data on a map

sample_Rcode_for_EQUATES_CMAQ_data.txt (5.0 KB)

5 Likes

Here’s the same excellent example adapted to use the terra package instead of the rgdal and raster packages, and eliminating the M3 package which seems to have gone away.

sample_Rcode_for_EQUATES_CMAQ_data_revised_v2.txt (9.4 KB)

(revised to use the same sample NetCDF file as the original)
(revised again to fix a problem with the leaflet image)

5 Likes

Wow, this is fantastic @DaveDixon. Thank you so much for sharing!! :grinning:

2 Likes