View source: R/thin_by_cell_time.R
thin_by_cell_time | R Documentation |
This function thins a dataset so that only one observation per cell per time slice is retained. We use a raster with layers as time slices to define the data cube on which thinning is enforced (see details below on how time should be formatted).
thin_by_cell_time(
data,
raster,
coords = NULL,
time_col = "time",
lubridate_fun = c,
drop_na = TRUE,
agg_fact = NULL
)
data |
An |
raster |
A |
coords |
a vector of length two giving the names of the "x" and "y"
coordinates, as found in |
time_col |
The name of the column with time; if time is not a lubridate
object, use |
lubridate_fun |
function to convert the time column into a lubridate object |
drop_na |
boolean on whether locations that are NA in the raster should be dropped. |
agg_fact |
positive integer. Aggregation factor expressed as number of
cells in each direction (horizontally and vertically). Or two integers
(horizontal and vertical aggregation factor) or three integers (when also
aggregating over layers). Defaults to NULL, which implies no aggregation
(i.e. thinning is done on the grid of |
Further spatial thinning can be achieved by aggregating cells in the raster
before thinning, as achieved by setting agg_fact
> 1 (aggregation works in
a manner equivalent to terra::aggregate()
). Note that if data
is an sf
object, the function will transform the coordinates to the same projection as
the raster
(recommended); if data
is a data.frame, it is up to the user
to ensure that the coordinates are in the correct units.
An object of class sf::sf
or data.frame
, the same as "data".
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.