Description Usage Arguments Details Value Author(s) See Also Examples
Extract NetCDF data
1 2 | openAndMatchNcdfData(filePath, method = c("ncdf4", "raster"), dayFilter,
coordinates, ...)
|
filePath |
A path to a NetCDF file. |
method |
Method (package) of extraction. Currently supports
either |
dayFilter |
Optional. A vector containing Date objects with dates of interest. |
coordinates |
Optional, only used if method is |
... |
Additional arguments to extract (used internally). |
Method ncdf4
uses the package to extract all layers using all coordinates.
Method raster
allows the user to specify arguments to the raster function
extract together with a table of coordinates of interest.
An array (longitude, latitude, time) containing variable of interest.
Diego Barneche.
1 2 3 4 5 6 7 8 9 10 11 12 | library(noaaErddap)
library(plyr)
nppFiles <- noaaErddapFiles('productivity', full.name = TRUE)
# extract NPP values for a given subset of coordinates (median value within a buffer of 20 km) across all files and take the mean
nppValues <- abind::abind(lapply(nppFiles, openAndMatchNcdfData, method = 'raster', coordinates = data.frame(Longitude = c(330, 335, 340), #' Latitude = c(-27, -19, 0)), buffer = 2e4, fun = median, na.rm = TRUE), along = 3)
apply(nppValues, c(1, 2), mean, na.rm = TRUE)
# extract the average NPP values for the globe in 1998
nppValues1998 <- abind::abind(lapply(nppFiles[grep('-1998.nc', nppFiles, fixed = TRUE)], openAndMatchNcdfData, method = 'ncdf4'), along = 3)
meanNPP1998 <- apply(nppValues1998, c(1, 2), mean, na.rm = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.