R/make_trast.R

Defines functions make_trast.track_xy make_trast

Documented in make_trast make_trast.track_xy

#' Create a template raster layer
#'
#' For some home-range estimation methods (e.g., KDE) a template raster is needed. This functions helps to quickly create such a template raster.
#' @param factor `[numeric(1)=1.5]{>= 1}`\cr Factor by which the extent of the relocations is extended.
#' @param res `[numeric(1)]`\cr Resolution of the output raster.
#' @template dots_none
#' @template track_xy_star
#' @name trast
#' @return A `RastLayer` without values.
#' @export
make_trast <- function(x, ...) {
  UseMethod("make_trast", x)
}

#' @export
#' @rdname trast
make_trast.track_xy <- function(x, factor = 1.5, res = max(c(extent_max(x) / 100, 1e-9)), ...) {
  res = max(c(amt::extent_max(x) / 100, 1e-9))

  checkmate::assert_number(factor, lower = 1)
  checkmate::assert_number(res, lower = 1e-10)

  me <- amt::extent_max(x)
  bu <- me * factor - me
  terra::rast(terra::vect(amt::bbox(x, buffer = bu)), res = res)
}

Try the amt package in your browser

Any scripts or data that you put into this service are public.

amt documentation built on March 31, 2023, 5:29 p.m.