View source: R/extract_covariates.R
extract_covariates | R Documentation |
Extract the covariate values at relocations, or at the beginning or end of steps.
extract_covariates(x, ...)
## S3 method for class 'track_xy'
extract_covariates(x, covariates, ...)
## S3 method for class 'random_points'
extract_covariates(x, covariates, ...)
## S3 method for class 'steps_xy'
extract_covariates(x, covariates, where = "end", ...)
extract_covariates_along(x, ...)
## S3 method for class 'steps_xy'
extract_covariates_along(x, covariates, ...)
extract_covariates_var_time(x, ...)
## S3 method for class 'track_xyt'
extract_covariates_var_time(
x,
covariates,
when = "any",
max_time,
name_covar = "time_var_covar",
...
)
## S3 method for class 'steps_xyt'
extract_covariates_var_time(
x,
covariates,
when = "any",
max_time,
name_covar = "time_var_covar",
where = "end",
...
)
x |
|
... |
Additional arguments passed to |
covariates |
|
where |
|
when |
|
max_time |
|
name_covar |
|
extract_covariates_along
extracts the covariates along a straight line between the start and the end point of a (random) step. It returns a list, which in most cases will have to be processed further.
A tibble
with additional columns for covariate values.
data(deer)
sh_forest <- get_sh_forest()
mini_deer <- deer[1:20, ]
mini_deer |> extract_covariates(sh_forest)
mini_deer |> steps() |> extract_covariates(sh_forest)
# Illustration of extracting covariates along the a step
mini_deer |> steps() |> random_steps() |>
extract_covariates(sh_forest) |> # extract at the endpoint
(\(.) mutate(., for_path = extract_covariates_along(., sh_forest)))() |>
# 1 = forest, lets calc the fraction of forest along the path
mutate(for_per = purrr::map_dbl(for_path, function(x) mean(x == 1)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.