matchEnvData | R Documentation |
Extracts all variables from a netcdf file matching Longitude, Latitude, and UTC coordinates in given dataframe
matchEnvData(
data,
nc = NULL,
var = NULL,
buffer = c(0, 0, 0),
FUN = c(mean),
fileName = NULL,
progress = TRUE,
depth = 0,
...
)
## S4 method for signature 'data.frame'
matchEnvData(
data,
nc = NULL,
var = NULL,
buffer = c(0, 0, 0),
FUN = c(mean),
fileName = NULL,
progress = TRUE,
depth = 0,
...
)
data |
dataframe containing Longitude, Latitude, and UTC to extract matching variables from the netcdf file |
nc |
name of a netcdf file, ERDDAP dataset id, or an edinfo object |
var |
(optional) vector of variable names |
buffer |
vector of Longitude, Latitude, and Time (seconds) to buffer around each datapoint. All values within the buffer will be used to report the mean, median, and standard deviation |
FUN |
a vector or list of functions to apply to the data. Default is to apply mean, median, and standard deviation calculations |
fileName |
(optional) file name to save downloaded nc file to. If not provided,
then no nc files will be stored, instead small temporary files will be downloaded
and then deleted. This can be much faster, but means that the data will need to be
downloaded again in the future. If |
progress |
logical flag to show progress bar |
depth |
depth values (meters) to use for matching, overrides any |
... |
other parameters to pass to ncToData |
original dataframe with three attached columns for each variable in the netcdf file, one for each of mean, median, and standard deviation of all values within the buffer
Taiki Sakai taiki.sakai@noaa.gov
data <- data.frame(Latitude = 32, Longitude = -117,
UTC = as.POSIXct('2004-12-31 09:00:00', tz='UTC'))
## Not run:
# Not run because downloads files
# default calculates mean, median, and standard deviation
matchEnvData(data, nc='jplMURSST41', var=c('analysed_sst', 'analysis_error'))
# get just mean within a buffer around coordinates
matchEnvData(data, nc='jplMURSST41', var=c('analysed_sst', 'analysis_error'),
FUN = mean, buffer = c(.01, .01, 86400))
## End(Not run)
# Can also work from an existing nc file
nc <- system.file('extdata', 'sst.nc', package='PAMmisc')
matchEnvData(data, nc = nc)
# Using a custom function
meanPlusOne <- function(x) {
mean(x, na.rm=TRUE) + 1
}
matchEnvData(data, nc=nc, FUN=c(mean, meanPlusOne))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.