Extract methods for raadtools read functions

# S4 method for `function`,data.frame
extract(x, y, ctstime = FALSE, fact = NULL, verbose = TRUE, ...)

Arguments

x

A raadtools read function.

y

Object to use for querying from the raadtools read functions, such as a vector of character, Date, or POSIXt values, data.frame, trip, etc.

ctstime

specify whether to find the nearest value in time (FALSE), or interpolate between slices (TRUE)

fact

integer. Aggregation factor expressed as number of cells in each direction (horizontally and vertically). Or two integers (horizontal and vertical aggregation factor). See Details in aggregate

verbose

report on progress or keep quiet

...

Additional arguments passed to the read function.

Value

data values extracted by the read functions

Details

Extract data from read functions in various ways.

See also

readsst and extract

Examples


a <- structure(list(x = c(174, 168, 156, 111, 99, 64, 52, 46, -4,
-15, -30, -38, -47, -62, -87, -127, -145, -160, -161), y = c(-72,
-39, -50, -58, -35, -38, -48, -60, -48, -35, -37, -51, -68, -72,
-69, -54, -40, -49, -54)), .Names = c("x", "y"), row.names = c(NA,
-19L), class = "data.frame")

a$time <- structure(c(5479, 5479, 5479, 5479, 5479, 5479, 5479, 5479, 5479,
5479, 5479, 5489, 5529, 5529, 5529, 5579, 5579, 5579, 5579), class = "Date")
extract(readsst, a)
#>  [1] -0.99 18.49 10.93  1.85 15.59 16.11  5.51  0.56  5.90 17.60 16.80  3.17
#> [13] -0.36    NA  0.43  6.10 15.53 11.56  7.77
extract(readsst, a, method = "bilinear")
#>  [1] -1.0700 18.4375 10.9700  1.9925 15.6750 16.2825  5.5925  0.6100  5.9325
#> [10] 17.7225 16.7800  3.6350 -0.3575 -0.9200  0.5025  6.2700 15.5300 11.5550
#> [19]  7.8575
a$time <-  sort(as.Date("2005-01-01") + sample(c(0, 0, 0, 8, 20, 50), nrow(a), replace = TRUE))
extract(readsst, a)
#>  [1] -0.16 16.22 10.71  3.13 16.71 17.32  4.60  0.04  4.16 17.45 16.63  3.96
#> [13] -1.68    NA -1.02  7.51 16.98 13.61  8.38