Skip to contents

Load package

knitr::opts_chunk$set(echo = TRUE)
devtools::install_github("GarrettLab/CroplandConnectivity",
                         subdir = "geohabnet", auth_token = "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")
#install.packages("geohabnet")
library(geohabnet)

Get raster

avo_rast <- get_rasters(list(monfreda = c("avocado")))
avo_rast

Currently supported distance methods

dmets <- dist_methods()
dmets

Install benchmark

Global Analysis

sa <- function(rast, distm) {
  sa_onrasters(rast,
               dist_method = distm,
               link_thresholds = c(0),
               host_density_thresholds = c(0))
}

Comparison of methods

bres <- microbenchmark(sa(avo_rast[[1]], dmets[1]),
                       sa(avo_rast[[1]], dmets[2]),
                       times = 1)
bres