R/hr_ud.R

Defines functions hr_ud.hr_prob hr_ud

Documented in hr_ud

#' Obtain the utilization distribution of a probabilistic home-range estimate
#'
#' @param x `[hr_prob]` The home-range estimate
#' @template dots_none
#' @return `SpatRaster`

#' @export
hr_ud <- function(x, ...) {
  UseMethod("hr_ud", x)
}

#' @export
hr_ud.hr_prob <- function(x, ...) {
  ud <- x$ud
  if (is(ud, "PackedSpatRaster")) {
    ud <- terra::unwrap(ud)
  }
  ud[] <- ud[] / sum(ud[], na.rm = TRUE)
  ud
}

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.