RPubs - How To Open and Work With NetCDF Data in R
RPubs - How To Open and Work With NetCDF Data in R
There are 10 global attributes which provide metadata information about the file.
Commentscode
We need to capture these data in the lat, lon, and time dimensions. The following (–) reads Share Hide Toolbars
the latitudes,
longitudes, and time of each NDVI observation and saves them in memory.
Read in the data from the NDVI variable and verify the dimensions of the array. There should be 4320 lons, 840
lats, and 31 times
Other pertinent information about the NDVI variable: Lets’s see what fill value was used for missing data.
## $hasatt
## [1] TRUE
##
## $value
## [1] -9999
All done reading in the data. We can close the netCDF file.
nc_close(nc_data)
First, a little housekeeping. Let’s replace all those pesky fill values with the R-standard ‘NA’.
Let’s get one year of the NDVI data and plot it.
Time is the third dimension of the “ndvi.array”. The first time slice represents the growing season of 1982.
https://rpubs.com/boyerag/297592?fbclid=IwAR3-gYtP9VawTI8pk9QRXiCWiR07hGKbGe2975q-EEBG-GUP3mm44QMz9WA 1/2
1/3/2019 RPubs - How to open and work with NetCDF data in R
https://rpubs.com/boyerag/297592?fbclid=IwAR3-gYtP9VawTI8pk9QRXiCWiR07hGKbGe2975q-EEBG-GUP3mm44QMz9WA 2/2