# Calculating home-range overlaps with `amt`

#### Johannes Signer and John Fieberg

#### 2025-08-23

## Background

Several different indices have been proposed for measuring home-range overlap. These are reviewed by Fieberg & Kochanny (2005). There are two general approaches used to calculate home-range overlap: 1) calculate the percentage overlap at a given isopleth level (this works for geometric and probabilistic home ranges) or 2) calculate an index of similarity between the two utilization distributions (UD; this only works for probabilistic estimators)1.

## Implementation in `amt`

`amt` currently implements all methods to calculate overlaps that were reviewed by Fieberg and Kochany (2005). These are:

- `hr`: That is the proportion of the home range of instance \(i\) that overlaps with the home range of instance \(j\). This measure does not rely on a UD and is directional (i.e., \(HR_{i,j} \ne HR_{j,i}\)) and bound between 0 (no overlap) and 1 (complete overlap)
- `phr`: Is the probability of instance \(j\) being located in the home range of instance \(i\). `phr` is also directional and bounded between 0 (no overlap) and 1 (complete overlap)
- `vi`: The volumetric intersection between two UDs.
- `ba`: The Bhattacharyya’s affinity between two UDs.
- `udoi`: A UD overlap index.
- `hd`: Hellinger’s distance between two UDs.

These overlap indices can be calculated with the function `hr_overlap`. The type of overlap measure an be controlled with the argument `type`.

All of these estimators can be calculated for a given home-range level (i.e., using conditional UDs). Whether or not a conditional overlap is desired or not, can be controlled with the argument `conditional`. For `hr`, the argument `conditional` has no effect and the isopleths used for home-range estimation will always be used for the overlap calculation.

The function `hr_overlap()` can also be provided with a list of home-range estimates in situations when overlap between many different instances are required. Currently, there are three options for calculating overlap among multiple instances: `which = "all"` calculates overlap for each pair of home ranges, `which = "one_to_all"` calculates overlap between the first element in the list and all others, and `which = "consecutive"` will calculate overlap between consecutive elements in the list.

## Examples

First we need to load the required packages:

    library(amt)
    library(ggplot2)
    library(tidygraph)
    library(ggraph)

### Two instances

We will use tracking data from Fishers from New York State, USA.

    leroy <- amt_fisher |> filter(name == "Leroy")
    lupe <- amt_fisher |> filter(name == "Lupe")

Create a template raster for the KDE

    trast <- make_trast(amt_fisher |> filter(name %in% c("Leroy", "Lupe")), res = 50)

And estimate home-ranges for both fishers

    hr_leroy <- hr_kde(leroy, trast = trast, levels = c(0.5, 0.9))
    hr_lupe <- hr_kde(lupe, trast = trast, levels = c(0.5, 0.9))

`hr` and `phr` are directional, this means the order matters. For all other overlap measures the order does not matter.

    hr_overlap(hr_leroy, hr_lupe, type = "hr")

    ## # A tibble: 2 × 2
    ##   levels overlap
    ##    <dbl>   <dbl>
    ## 1    0.9   0.309
    ## 2    0.5   0.191

    hr_overlap(hr_lupe, hr_leroy, type = "hr")

    ## # A tibble: 2 × 2
    ##   levels overlap
    ##    <dbl>   <dbl>
    ## 1    0.9   0.986
    ## 2    0.5   0.574

By default `conditional = FALSE` and the full UD is used.

    hr_overlap(hr_leroy, hr_lupe, type = "phr", conditional = FALSE)

    ## # A tibble: 1 × 2
    ##   levels overlap
    ##    <dbl>   <dbl>
    ## 1      1   1.000

    hr_overlap(hr_lupe, hr_leroy, type = "phr", conditional = FALSE)

    ## # A tibble: 1 × 2
    ##   levels overlap
    ##    <dbl>   <dbl>
    ## 1      1   0.767

If we set `conditional = TRUE`, the overlap is measured at home-range levels that were specified during estimation.

    hr_overlap(hr_leroy, hr_lupe, type = "phr", conditional = TRUE)

    ## # A tibble: 2 × 2
    ##   levels overlap
    ##    <dbl>   <dbl>
    ## 1    0.5   0.580
    ## 2    0.9   0.992

    hr_overlap(hr_lupe, hr_leroy, type = "phr", conditional = TRUE)

    ## # A tibble: 2 × 2
    ##   levels overlap
    ##    <dbl>   <dbl>
    ## 1    0.5   0.221
    ## 2    0.9   0.401

Note, for the remaining overlap measures the order does not matter. Below we show this for the volumnic intersection (`type = "vi"`) as an example.

    hr_overlap(hr_lupe, hr_leroy, type = "vi", conditional = FALSE)

    ## # A tibble: 1 × 2
    ##   levels overlap
    ##    <dbl>   <dbl>
    ## 1      1   0.439

    hr_overlap(hr_leroy, hr_lupe, type = "vi", conditional = FALSE)

    ## # A tibble: 1 × 2
    ##   levels overlap
    ##    <dbl>   <dbl>
    ## 1      1   0.439

### \(> 2\) instances

Lets calculate daily ranges for Lupe and then and then see how different ranges overlap with each other.

We have to use the same template raster in order to make ranges comparable.

    trast <- make_trast(lupe, res = 50)

Then we add a new column with day and calculate for each day a `KDE` home range.

    dat <- lupe |>
      mutate(week = lubridate::floor_date(t_, "week")) |>
      nest(data = -week) |>
      mutate(kde = map(data, hr_kde, trast = trast, levels = c(0.5, 0.95, 0.99)))

Now we can use the list column with the home-range estimates to calculate overlap between the different home-ranges. By default `which = "consecutive"`, this means for each list entry (= home-range estimate) the overlap to the next entry will be calculated.

    hr_overlap(dat$kde, type = "vi")

    ## # A tibble: 3 × 4
    ##    from    to levels overlap
    ##   <int> <int>  <dbl>   <dbl>
    ## 1     1     2      1  0.0431
    ## 2     2     3      1  0.551
    ## 3     3     4      1  0.612

This works as well, if we set `conditional = TRUE`:

    hr_overlap(dat$kde, type = "vi", conditional = TRUE)

    ## # A tibble: 9 × 4
    ##    from    to levels overlap
    ##   <int> <int>  <dbl>   <dbl>
    ## 1     1     2   0.5   0
    ## 2     1     2   0.95  0.0264
    ## 3     1     2   0.99  0.0357
    ## 4     2     3   0.5   0.264
    ## 5     2     3   0.95  0.528
    ## 6     2     3   0.99  0.547
    ## 7     3     4   0.5   0.318
    ## 8     3     4   0.95  0.592
    ## 9     3     4   0.99  0.608

Sometimes it can be useful to provide meaningful labels. We can do this with the `labels` argument.

    hr_overlap(dat$kde, type = "vi", labels = dat$week)

    ## # A tibble: 3 × 4
    ##   from       to         levels overlap
    ##   <chr>      <chr>       <dbl>   <dbl>
    ## 1 2010-12-12 2010-12-19      1  0.0431
    ## 2 2010-12-19 2010-12-26      1  0.551
    ## 3 2010-12-26 2011-01-02      1  0.612

Different options exist for the argument `which`. For example, `which = "one_to_all"` calculates the overlap between the first and all other home ranges.

## Overlap between a home range and a simple feature

The function `hr_overlap_feature` allows to calculate percentage overlap (\(HR\) index) between a home. To illustrate this feature, we will use again the data from `lupe` and calculate the intersection with an arbitrary polygon.

    poly <- amt::bbox(lupe, buffer = -500, sf = TRUE)
    poly1 <- amt::bbox(lupe, sf = TRUE)
    hr <- hr_mcp(lupe)
    ggplot() + geom_sf(data = hr_isopleths(hr)) +
      geom_sf(data = poly, fill = NA, col = "red") +
      geom_sf(data = poly1, fill = NA, col = "blue")

    hr_overlap_feature(hr, poly, direction = "hr_with_feature")

    ## # A tibble: 1 × 3
    ##    from    to overlap
    ##   <dbl> <int>   <dbl>
    ## 1  0.95     1   0.828

    hr_overlap_feature(hr, poly1, direction = "hr_with_feature")

    ## # A tibble: 1 × 3
    ##    from    to overlap
    ##   <dbl> <int>   <dbl>
    ## 1  0.95     1   1.000

    hr_overlap_feature(hr, poly, direction = "feature_with_hr")

    ## # A tibble: 1 × 3
    ##    from    to overlap
    ##   <int> <dbl>   <dbl>
    ## 1     1  0.95   0.854

    hr_overlap_feature(hr, poly1, direction = "feature_with_hr")

    ## # A tibble: 1 × 3
    ##    from    to overlap
    ##   <int> <dbl>   <dbl>
    ## 1     1  0.95   0.542

The same work with several home-range levels:

    hr <- hr_mcp(lupe, levels = c(0.5, 0.9, 0.95))
    hr_overlap_feature(hr, poly, direction = "hr_with_feature")

    ## # A tibble: 3 × 3
    ##    from    to overlap
    ##   <dbl> <int>   <dbl>
    ## 1  0.5      1   0.828
    ## 2  0.9      1   0.860
    ## 3  0.95     1   0.990

## References

- Fieberg, J., & Kochanny, C. O. (2005). Quantifying home‐range overlap: the importance of the utilization distribution. The Journal of Wildlife Management, 69(4), 1346-1359.

## Session

    sessioninfo::session_info()

    ## ─ Session info ───────────────────────────────────────────────────────────────
    ##  setting  value
    ##  version  R version 4.5.1 (2025-06-13)
    ##  os       macOS Sequoia 15.6
    ##  system   aarch64, darwin20
    ##  ui       X11
    ##  language (EN)
    ##  collate  C
    ##  ctype    en_US.UTF-8
    ##  tz       Europe/Berlin
    ##  date     2025-08-23
    ##  pandoc   3.4 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/aarch64/ (via rmarkdown)
    ##  quarto   1.6.40 @ /usr/local/bin/quarto
    ##
    ## ─ Packages ───────────────────────────────────────────────────────────────────
    ##  package      * version date (UTC) lib source
    ##  amt          * 0.3.0.0 2025-08-23 [1] local
    ##  backports      1.5.0   2024-05-23 [3] CRAN (R 4.5.0)
    ##  bslib          0.9.0   2025-01-30 [3] CRAN (R 4.5.0)
    ##  cachem         1.1.0   2024-05-16 [3] CRAN (R 4.5.0)
    ##  checkmate      2.3.3   2025-08-18 [3] CRAN (R 4.5.0)
    ##  class          7.3-23  2025-01-01 [3] CRAN (R 4.5.1)
    ##  classInt       0.4-11  2025-01-08 [3] CRAN (R 4.5.0)
    ##  cli            3.6.5   2025-04-23 [3] CRAN (R 4.5.0)
    ##  codetools      0.2-20  2024-03-31 [3] CRAN (R 4.5.1)
    ##  data.table     1.17.8  2025-07-10 [3] CRAN (R 4.5.0)
    ##  DBI            1.2.3   2024-06-02 [3] CRAN (R 4.5.0)
    ##  digest         0.6.37  2024-08-19 [3] CRAN (R 4.5.0)
    ##  dplyr        * 1.1.4   2023-11-17 [3] CRAN (R 4.5.0)
    ##  e1071          1.7-16  2024-09-16 [3] CRAN (R 4.5.0)
    ##  evaluate       1.0.4   2025-06-18 [3] CRAN (R 4.5.0)
    ##  farver         2.1.2   2024-05-13 [3] CRAN (R 4.5.0)
    ##  fastmap        1.2.0   2024-05-15 [3] CRAN (R 4.5.0)
    ##  generics       0.1.4   2025-05-09 [3] CRAN (R 4.5.0)
    ##  ggforce        0.5.0   2025-06-18 [3] CRAN (R 4.5.0)
    ##  ggplot2      * 3.5.2   2025-04-09 [3] CRAN (R 4.5.0)
    ##  ggraph       * 2.2.1   2024-03-07 [3] CRAN (R 4.5.0)
    ##  ggrepel        0.9.6   2024-09-07 [3] CRAN (R 4.5.0)
    ##  glue           1.8.0   2024-09-30 [3] CRAN (R 4.5.0)
    ##  graphlayouts   1.2.2   2025-01-23 [3] CRAN (R 4.5.0)
    ##  gridExtra      2.3     2017-09-09 [3] CRAN (R 4.5.0)
    ##  gtable         0.3.6   2024-10-25 [3] CRAN (R 4.5.0)
    ##  htmltools      0.5.8.1 2024-04-04 [3] CRAN (R 4.5.0)
    ##  igraph         2.1.4   2025-01-23 [3] CRAN (R 4.5.0)
    ##  jquerylib      0.1.4   2021-04-26 [3] CRAN (R 4.5.0)
    ##  jsonlite       2.0.0   2025-03-27 [3] CRAN (R 4.5.0)
    ##  KernSmooth     2.23-26 2025-01-01 [3] CRAN (R 4.5.1)
    ##  knitr          1.50    2025-03-16 [3] CRAN (R 4.5.0)
    ##  labeling       0.4.3   2023-08-29 [3] CRAN (R 4.5.0)
    ##  lattice        0.22-7  2025-04-02 [3] CRAN (R 4.5.1)
    ##  lifecycle      1.0.4   2023-11-07 [3] CRAN (R 4.5.0)
    ##  lubridate      1.9.4   2024-12-08 [3] CRAN (R 4.5.0)
    ##  magrittr       2.0.3   2022-03-30 [3] CRAN (R 4.5.0)
    ##  MASS           7.3-65  2025-02-28 [3] CRAN (R 4.5.1)
    ##  Matrix         1.7-3   2025-03-11 [3] CRAN (R 4.5.1)
    ##  memoise        2.0.1   2021-11-26 [3] CRAN (R 4.5.0)
    ##  pillar         1.11.0  2025-07-04 [3] CRAN (R 4.5.0)
    ##  pkgconfig      2.0.3   2019-09-22 [3] CRAN (R 4.5.0)
    ##  polyclip       1.10-7  2024-07-23 [3] CRAN (R 4.5.0)
    ##  proxy          0.4-27  2022-06-09 [3] CRAN (R 4.5.0)
    ##  purrr          1.1.0   2025-07-10 [3] CRAN (R 4.5.0)
    ##  R6             2.6.1   2025-02-15 [3] CRAN (R 4.5.0)
    ##  rbibutils      2.3     2024-10-04 [3] CRAN (R 4.5.0)
    ##  RColorBrewer   1.1-3   2022-04-03 [3] CRAN (R 4.5.0)
    ##  Rcpp           1.1.0   2025-07-02 [3] CRAN (R 4.5.0)
    ##  Rdpack         2.6.4   2025-04-09 [3] CRAN (R 4.5.0)
    ##  rlang          1.1.6   2025-04-11 [3] CRAN (R 4.5.0)
    ##  rmarkdown      2.29    2024-11-04 [3] CRAN (R 4.5.0)
    ##  rstudioapi     0.17.1  2024-10-22 [3] CRAN (R 4.5.0)
    ##  sass           0.4.10  2025-04-11 [3] CRAN (R 4.5.0)
    ##  scales         1.4.0   2025-04-24 [3] CRAN (R 4.5.0)
    ##  sessioninfo    1.2.3   2025-02-05 [3] CRAN (R 4.5.0)
    ##  sf             1.0-21  2025-05-15 [3] CRAN (R 4.5.0)
    ##  survival       3.8-3   2024-12-17 [3] CRAN (R 4.5.1)
    ##  terra          1.8-60  2025-07-21 [3] CRAN (R 4.5.0)
    ##  tibble         3.3.0   2025-06-08 [3] CRAN (R 4.5.0)
    ##  tidygraph    * 1.3.1   2024-01-30 [3] CRAN (R 4.5.0)
    ##  tidyr          1.3.1   2024-01-24 [3] CRAN (R 4.5.0)
    ##  tidyselect     1.2.1   2024-03-11 [3] CRAN (R 4.5.0)
    ##  timechange     0.3.0   2024-01-18 [3] CRAN (R 4.5.0)
    ##  tweenr         2.0.3   2024-02-26 [3] CRAN (R 4.5.0)
    ##  units          0.8-7   2025-03-11 [3] CRAN (R 4.5.0)
    ##  utf8           1.2.6   2025-06-08 [3] CRAN (R 4.5.0)
    ##  vctrs          0.6.5   2023-12-01 [3] CRAN (R 4.5.0)
    ##  viridis        0.6.5   2024-01-29 [3] CRAN (R 4.5.0)
    ##  viridisLite    0.4.2   2023-05-02 [3] CRAN (R 4.5.0)
    ##  withr          3.0.2   2024-10-28 [3] CRAN (R 4.5.0)
    ##  xfun           0.53    2025-08-19 [3] CRAN (R 4.5.0)
    ##  yaml           2.3.10  2024-07-26 [3] CRAN (R 4.5.0)
    ##
    ##  [1] /private/var/folders/ln/h3zng0fs2pq7mhn_hzn0d8x00000gn/T/RtmpvmiLWg/Rinst1761f5e417fe9
    ##  [2] /private/var/folders/ln/h3zng0fs2pq7mhn_hzn0d8x00000gn/T/RtmpfKQTmf/temp_libpath16445556b59c1
    ##  [3] /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library
    ##  * ── Packages attached to the search path.
    ##
    ## ──────────────────────────────────────────────────────────────────────────────

1. For a discussion of geometric vs. probabilistic estimators see here: https://peerj.com/articles/11031/↩︎