This function is used to sample environmental conditions from within the detection containers of receivers. To implement the function, a SpatialPoints object that defines receiver locations (xy) must be provided, along with the detection range (detection_range) of receivers. This information is used to define detection containers, via get_detection_containers. Within each receiver's container, all values of an environmental variable, or a random sample of values, are extracted from a user-defined raster (envir). Under random sampling, values can be sampled according to a detection probability function (sample_probs). The function returns a list of dataframes, one for each receiver, that include the sampled values.

get_detection_containers_envir(
  xy,
  detection_range,
  coastline,
  plot = FALSE,
  envir,
  sample_size = NULL,
  sample_replace = TRUE,
  sample_probs = NULL,
  cl = NULL,
  varlist = NULL,
  verbose = TRUE,
  ...
)

Arguments

xy, detection_range, coastline, plot, ...

Arguments required to calculate and visualise detection containers via get_detection_containers; namely, receiver locations (xy), the detection range (detection_range), barriers to detection (coastline) and whether or not to plot the containers (plot). Additional arguments can be passed via ... but note that byid is necessarily TRUE and should not be provided.

envir

A raster that defines the values of an environmental variable across the study area. The coordinate reference system should be the Universal Transverse Mercator system.

sample_size

(optional) An integer that defines the number of samples of the environmental variable to draw from the area around each receiver (see the `size' argument of sample). If this is provided, sample_size samples are taken from this area; otherwise, all values are extracted.

sample_replace

(optional) If sample_size is specified, sample_replace is a logical input that defines whether to implement sampling with (sample_replace = TRUE, the default) or without (sample_replace = FALSE) replacement (see the `replace' argument of sample).

sample_probs

(optional) If sample_size is specified, sample_probs is a function that calculates the detection probability given the distance (m) between a cell and a receiver.

cl, varlist

(optional) Parallelisation options. cl is (a) a cluster object from makeCluster or (b) an integer that defines the number of child processes. varlist is a character vector of variables for export (see cl_export). Exported variables must be located in the global environment. If a cluster is supplied, the connection to the cluster is closed within the function (see cl_stop). For further information, see cl_lapply and flapper-tips-parallel.

verbose

A logical variable that defines whether or not relay messages to the console to monitor function progress.

Value

The function returns a list of dataframes (one for each element in xy; i.e., each receiver), each of which includes the cell IDs of envir from which values were extracted (`cell'), the value of the environmental variable in that cell (`envir') and, if applicable, the distance between that cell and the receiver (`dist', m) and the detection probability in that cell (`prob').

Author

Edward Lavender

Examples

#### Define receiver locations as a SpatialPoints object with a UTM CRS
proj_wgs84 <- sp::CRS(SRS_string = "EPSG:4326")
proj_utm <- sp::CRS(SRS_string = "EPSG:32629")
xy <- sp::SpatialPoints(
  dat_moorings[, c("receiver_long", "receiver_lat")],
  proj_wgs84
)
xy <- sp::spTransform(xy, proj_utm)
xy@data <- as.data.frame(xy)

#### Example (1): Extract all depth values within each receiver's container
depths_by_container <-
  get_detection_containers_envir(
    xy = xy,
    detection_range = 425,
    coastline = dat_coast,
    envir = dat_gebco
  )
#> flapper::get_detection_containers_envir() called (@ 2023-08-29 15:42:06)... 
#> ... Implementing function checks... 
#> ... Defining detection container(s)... 
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> ... Extracting environmental conditions from detection area(s)... 
# The function returns a list of dataframes, one for each receiver
# ... with the cell IDs and the value of the environmental variable
utils::str(depths_by_container)
#> List of 40
#>  $ :'data.frame':	5 obs. of  2 variables:
#>   ..$ cell : num [1:5] 3003 3004 3076 3077 3078
#>   ..$ envir: num [1:5] 58 69.9 69.2 99.3 107.1
#>  $ :'data.frame':	3 obs. of  2 variables:
#>   ..$ cell : num [1:3] 869 870 871
#>   ..$ envir: num [1:3] 175 167 152
#>  $ :'data.frame':	3 obs. of  2 variables:
#>   ..$ cell : num [1:3] 643 644 645
#>   ..$ envir: num [1:3] 72.1 138.1 141.4
#>  $ :'data.frame':	4 obs. of  2 variables:
#>   ..$ cell : num [1:4] 3000 3001 3002 3003
#>   ..$ envir: num [1:4] NA 25.4 29.8 58
#>  $ :'data.frame':	4 obs. of  2 variables:
#>   ..$ cell : num [1:4] 860 861 862 863
#>   ..$ envir: num [1:4] 145 157 166 180
#>  $ :'data.frame':	4 obs. of  2 variables:
#>   ..$ cell : num [1:4] 871 944 945 946
#>   ..$ envir: num [1:4] 152 176 162 135
#>  $ :'data.frame':	4 obs. of  2 variables:
#>   ..$ cell : num [1:4] 1067 1068 1069 1142
#>   ..$ envir: num [1:4] 53.5 48.4 25.2 101.9
#>  $ :'data.frame':	6 obs. of  2 variables:
#>   ..$ cell : num [1:6] 1679 1680 1752 1753 1754 ...
#>   ..$ envir: num [1:6] 49 43.5 56.3 55 46.9 ...
#>  $ :'data.frame':	4 obs. of  2 variables:
#>   ..$ cell : num [1:4] 1285 1286 1287 1360
#>   ..$ envir: num [1:4] 14.5 22 22.9 19.3
#>  $ :'data.frame':	4 obs. of  2 variables:
#>   ..$ cell : num [1:4] 3233 3234 3235 3308
#>   ..$ envir: num [1:4] 104.9 85.5 61.3 48.5
#>  $ :'data.frame':	4 obs. of  2 variables:
#>   ..$ cell : num [1:4] 1212 1213 1214 1287
#>   ..$ envir: num [1:4] 28 28.5 28.8 22.9
#>  $ :'data.frame':	4 obs. of  2 variables:
#>   ..$ cell : num [1:4] 1681 1682 1683 1755
#>   ..$ envir: num [1:4] 47.6 25.6 32.5 32.2
#>  $ :'data.frame':	6 obs. of  2 variables:
#>   ..$ cell : num [1:6] 3161 3162 3163 3235 3236 ...
#>   ..$ envir: num [1:6] 104 71.9 47.5 61.3 47.9 ...
#>  $ :'data.frame':	5 obs. of  2 variables:
#>   ..$ cell : num [1:5] 3587 3588 3660 3661 3662
#>   ..$ envir: num [1:5] 107 113 106 108 115
#>  $ :'data.frame':	5 obs. of  2 variables:
#>   ..$ cell : num [1:5] 830 831 832 904 905
#>   ..$ envir: num [1:5] 117.1 118.1 108.7 76.1 84.4
#>  $ :'data.frame':	4 obs. of  2 variables:
#>   ..$ cell : num [1:4] 3229 3230 3231 3232
#>   ..$ envir: num [1:4] 68.8 79 107.1 116.5
#>  $ :'data.frame':	4 obs. of  2 variables:
#>   ..$ cell : num [1:4] 3163 3164 3165 3238
#>   ..$ envir: num [1:4] 47.5 40.4 32.8 35
#>  $ :'data.frame':	4 obs. of  2 variables:
#>   ..$ cell : num [1:4] 3153 3154 3155 3156
#>   ..$ envir: num [1:4] 118.9 112.5 94 84.7
#>  $ :'data.frame':	5 obs. of  2 variables:
#>   ..$ cell : num [1:5] 1531 1532 1604 1605 1606
#>   ..$ envir: num [1:5] 43.8 28.6 55.3 47.2 36.1
#>  $ :'data.frame':	5 obs. of  2 variables:
#>   ..$ cell : num [1:5] 2866 2867 2868 2940 2941
#>   ..$ envir: num [1:5] 135 123 120 130 127
#>  $ :'data.frame':	6 obs. of  2 variables:
#>   ..$ cell : num [1:6] 3374 3375 3376 3448 3449 ...
#>   ..$ envir: num [1:6] 72.1 75.3 90.4 89.9 92.5 ...
#>  $ :'data.frame':	5 obs. of  2 variables:
#>   ..$ cell : num [1:5] 1749 1750 1751 1824 1825
#>   ..$ envir: num [1:5] 50.8 61.5 57.8 64.9 73.1
#>  $ :'data.frame':	6 obs. of  2 variables:
#>   ..$ cell : num [1:6] 1222 1223 1224 1296 1297 ...
#>   ..$ envir: num [1:6] 131 132 133 105 102 ...
#>  $ :'data.frame':	3 obs. of  2 variables:
#>   ..$ cell : num [1:3] 794 795 796
#>   ..$ envir: num [1:3] 179 174 161
#>  $ :'data.frame':	4 obs. of  2 variables:
#>   ..$ cell : num [1:4] 994 1067 1068 1069
#>   ..$ envir: num [1:4] NA 53.5 48.4 25.2
#>  $ :'data.frame':	4 obs. of  2 variables:
#>   ..$ cell : num [1:4] 3230 3231 3232 3305
#>   ..$ envir: num [1:4] 79 107.1 116.5 89.3
#>  $ :'data.frame':	4 obs. of  2 variables:
#>   ..$ cell : num [1:4] 1018 1019 1020 1093
#>   ..$ envir: num [1:4] 159 126.8 83.2 75.9
#>  $ :'data.frame':	5 obs. of  2 variables:
#>   ..$ cell : num [1:5] 3087 3088 3161 3162 3163
#>   ..$ envir: num [1:5] 141.8 114.8 104 71.9 47.5
#>  $ :'data.frame':	6 obs. of  2 variables:
#>   ..$ cell : num [1:6] 1137 1138 1139 1211 1212 ...
#>   ..$ envir: num [1:6] 22.2 21.6 22 20.4 28 ...
#>  $ :'data.frame':	3 obs. of  2 variables:
#>   ..$ cell : num [1:3] 1065 1066 1067
#>   ..$ envir: num [1:3] 57.5 71.6 53.5
#>  $ :'data.frame':	4 obs. of  2 variables:
#>   ..$ cell : num [1:4] 3079 3080 3081 3154
#>   ..$ envir: num [1:4] 102 137 142 112
#>  $ :'data.frame':	3 obs. of  2 variables:
#>   ..$ cell : num [1:3] 3002 3003 3004
#>   ..$ envir: num [1:3] 29.8 58 69.9
#>  $ :'data.frame':	6 obs. of  2 variables:
#>   ..$ cell : num [1:6] 1898 1899 1900 1972 1973 ...
#>   ..$ envir: num [1:6] 60 80.7 64.9 45.3 55.8 ...
#>  $ :'data.frame':	6 obs. of  2 variables:
#>   ..$ cell : num [1:6] 1895 1896 1897 1969 1970 ...
#>   ..$ envir: num [1:6] 31.9 32.5 38.5 34.5 33.8 ...
#>  $ :'data.frame':	6 obs. of  2 variables:
#>   ..$ cell : num [1:6] 1064 1065 1137 1138 1139 ...
#>   ..$ envir: num [1:6] 32.7 57.5 22.2 21.6 22 ...
#>  $ :'data.frame':	5 obs. of  2 variables:
#>   ..$ cell : num [1:5] 2927 2928 2929 3001 3002
#>   ..$ envir: num [1:5] NA 14 31.2 25.4 29.8
#>  $ :'data.frame':	6 obs. of  2 variables:
#>   ..$ cell : num [1:6] 1210 1211 1212 1213 1285 ...
#>   ..$ envir: num [1:6] 19 20.4 28 28.5 14.5 ...
#>  $ :'data.frame':	4 obs. of  2 variables:
#>   ..$ cell : num [1:4] 3165 3166 3167 3168
#>   ..$ envir: num [1:4] 32.8 47.7 58.5 29.4
#>  $ :'data.frame':	6 obs. of  2 variables:
#>   ..$ cell : num [1:6] 3162 3163 3164 3165 3237 ...
#>   ..$ envir: num [1:6] 71.9 47.5 40.4 32.8 42.8 ...
#>  $ :'data.frame':	4 obs. of  2 variables:
#>   ..$ cell : num [1:4] 3232 3233 3234 3307
#>   ..$ envir: num [1:4] 116.5 104.9 85.5 54.9
# Collapse the list and compare conditions across receivers
depths_by_container <-
  lapply(1:length(depths_by_container), function(i) {
    d <- depths_by_container[[i]]
    d$receiver_id <- dat_moorings$receiver_id[i]
    return(d)
  })
depths_by_container <- dplyr::bind_rows(depths_by_container)
prettyGraphics::pretty_boxplot(
  depths_by_container$receiver_id,
  depths_by_container$envir
)
#> 'x' co-erced to a factor.
#> 3 observation pair(s) in x are NA; these are removed.


#### Example (2): Extract a random sample of values
# (We'll keep the values small for speed)
depths_by_container <-
  get_detection_containers_envir(
    xy = xy,
    detection_range = 425,
    coastline = dat_coast,
    envir = dat_gebco,
    sample_size = 2
  )
#> flapper::get_detection_containers_envir() called (@ 2023-08-29 15:42:07)... 
#> ... Implementing function checks... 
#> ... Defining detection container(s)... 
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> ... Extracting environmental conditions from detection area(s)... 
utils::str(depths_by_container)
#> List of 40
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 3078 3004
#>   ..$ envir: num [1:2] 107.1 69.9
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 871 869
#>   ..$ envir: num [1:2] 152 175
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 645 644
#>   ..$ envir: num [1:2] 141 138
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 3000 3000
#>   ..$ envir: num [1:2] NA NA
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 862 861
#>   ..$ envir: num [1:2] 166 157
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 945 871
#>   ..$ envir: num [1:2] 162 152
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 1142 1142
#>   ..$ envir: num [1:2] 102 102
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 1680 1755
#>   ..$ envir: num [1:2] 43.5 32.2
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 1286 1286
#>   ..$ envir: num [1:2] 22 22
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 3233 3308
#>   ..$ envir: num [1:2] 104.9 48.5
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 1287 1213
#>   ..$ envir: num [1:2] 22.9 28.5
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 1682 1683
#>   ..$ envir: num [1:2] 25.6 32.5
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 3235 3163
#>   ..$ envir: num [1:2] 61.3 47.5
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 3661 3661
#>   ..$ envir: num [1:2] 108 108
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 905 832
#>   ..$ envir: num [1:2] 84.4 108.7
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 3230 3229
#>   ..$ envir: num [1:2] 79 68.8
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 3238 3165
#>   ..$ envir: num [1:2] 35 32.8
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 3155 3156
#>   ..$ envir: num [1:2] 94 84.7
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 1605 1605
#>   ..$ envir: num [1:2] 47.2 47.2
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 2867 2941
#>   ..$ envir: num [1:2] 123 127
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 3449 3450
#>   ..$ envir: num [1:2] 92.5 93.9
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 1751 1824
#>   ..$ envir: num [1:2] 57.8 64.9
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 1298 1224
#>   ..$ envir: num [1:2] 105 133
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 796 794
#>   ..$ envir: num [1:2] 161 179
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 1069 1067
#>   ..$ envir: num [1:2] 25.2 53.5
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 3231 3305
#>   ..$ envir: num [1:2] 107.1 89.3
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 1018 1020
#>   ..$ envir: num [1:2] 159 83.2
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 3161 3161
#>   ..$ envir: num [1:2] 104 104
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 1139 1211
#>   ..$ envir: num [1:2] 22 20.4
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 1067 1066
#>   ..$ envir: num [1:2] 53.5 71.6
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 3154 3080
#>   ..$ envir: num [1:2] 112 137
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 3002 3002
#>   ..$ envir: num [1:2] 29.8 29.8
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 1900 1972
#>   ..$ envir: num [1:2] 64.9 45.3
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 1896 1896
#>   ..$ envir: num [1:2] 32.5 32.5
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 1065 1137
#>   ..$ envir: num [1:2] 57.5 22.2
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 2928 2928
#>   ..$ envir: num [1:2] 14 14
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 1286 1285
#>   ..$ envir: num [1:2] 22 14.5
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 3168 3168
#>   ..$ envir: num [1:2] 29.4 29.4
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 3238 3238
#>   ..$ envir: num [1:2] 35 35
#>  $ :'data.frame':	2 obs. of  2 variables:
#>   ..$ cell : num [1:2] 3234 3234
#>   ..$ envir: num [1:2] 85.5 85.5

#### Example (3) Extract a random sample of values with weighted probabilities
# Define detection probability function based only on distance
calc_detection_pr <-
  function(dist) {
    dpr <- get_detection_pr(
      distance = dist,
      beta_0 = 2.5,
      beta_1 = -0.01,
      inv_link = stats::plogis,
      output = 2L
    )
    return(dpr)
  }
# Implement sampling with replacement according to detection probability
depths_by_container <-
  get_detection_containers_envir(
    xy = xy,
    detection_range = 425,
    coastline = dat_coast,
    envir = dat_gebco,
    sample_size = 2,
    sample_probs = calc_detection_pr
  )
#> flapper::get_detection_containers_envir() called (@ 2023-08-29 15:42:08)... 
#> ... Implementing function checks... 
#> ... Defining detection container(s)... 
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> ... Extracting environmental conditions from detection area(s)... 
# Each element of the outputted list includes the 'cell' and 'envir' column
# ... as well as 'dist' and 'prob' that define the distance of that cell
# ... from the location in xy and the corresponding detection probability
# ... at that distance respectively
utils::str(depths_by_container)
#> List of 40
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3077 3078
#>   ..$ envir: num [1:2] 99.3 107.1
#>   ..$ dist : num [1:2] 178 261
#>   ..$ prob : num [1:2] 0.673 0.473
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 871 869
#>   ..$ envir: num [1:2] 152 175
#>   ..$ dist : num [1:2] 255 259
#>   ..$ prob : num [1:2] 0.488 0.477
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 643 645
#>   ..$ envir: num [1:2] 72.1 141.4
#>   ..$ dist : num [1:2] 307 209
#>   ..$ prob : num [1:2] 0.361 0.6
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3002 3000
#>   ..$ envir: num [1:2] 29.8 NA
#>   ..$ dist : num [1:2] 122 398
#>   ..$ prob : num [1:2] 0.782 0.186
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 862 863
#>   ..$ envir: num [1:2] 166 180
#>   ..$ dist : num [1:2] 157 414
#>   ..$ prob : num [1:2] 0.716 0.162
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 944 946
#>   ..$ envir: num [1:2] 176 135
#>   ..$ dist : num [1:2] 326 203
#>   ..$ prob : num [1:2] 0.318 0.616
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1069 1067
#>   ..$ envir: num [1:2] 25.2 53.5
#>   ..$ dist : num [1:2] 228 294
#>   ..$ prob : num [1:2] 0.554 0.393
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1753 1752
#>   ..$ envir: num [1:2] 55 56.3
#>   ..$ dist : num [1:2] 173 406
#>   ..$ prob : num [1:2] 0.684 0.173
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1360 1286
#>   ..$ envir: num [1:2] 19.3 22
#>   ..$ dist : num [1:2] 420.3 65.3
#>   ..$ prob : num [1:2] 0.154 0.864
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3234 3233
#>   ..$ envir: num [1:2] 85.5 104.9
#>   ..$ dist : num [1:2] 58.9 45.5
#>   ..$ prob : num [1:2] 0.871 0.885
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1212 1213
#>   ..$ envir: num [1:2] 28 28.5
#>   ..$ dist : num [1:2] 195.2 67.5
#>   ..$ prob : num [1:2] 0.634 0.861
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1682 1755
#>   ..$ envir: num [1:2] 25.6 32.2
#>   ..$ dist : num [1:2] 192 338
#>   ..$ prob : num [1:2] 0.642 0.293
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3161 3162
#>   ..$ envir: num [1:2] 104 71.9
#>   ..$ dist : num [1:2] 206 177
#>   ..$ prob : num [1:2] 0.609 0.675
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3661 3662
#>   ..$ envir: num [1:2] 108 115
#>   ..$ dist : num [1:2] 125 235
#>   ..$ prob : num [1:2] 0.778 0.538
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 832 831
#>   ..$ envir: num [1:2] 109 118
#>   ..$ dist : num [1:2] 411 204
#>   ..$ prob : num [1:2] 0.167 0.614
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3230 3229
#>   ..$ envir: num [1:2] 79 68.8
#>   ..$ dist : num [1:2] 95.5 352.4
#>   ..$ prob : num [1:2] 0.824 0.264
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3164 3165
#>   ..$ envir: num [1:2] 40.4 32.8
#>   ..$ dist : num [1:2] 101 241
#>   ..$ prob : num [1:2] 0.817 0.522
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3155 3154
#>   ..$ envir: num [1:2] 94 112
#>   ..$ dist : num [1:2] 131 148
#>   ..$ prob : num [1:2] 0.767 0.736
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1605 1605
#>   ..$ envir: num [1:2] 47.2 47.2
#>   ..$ dist : num [1:2] 228 228
#>   ..$ prob : num [1:2] 0.555 0.555
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 2867 2867
#>   ..$ envir: num [1:2] 123 123
#>   ..$ dist : num [1:2] 173 173
#>   ..$ prob : num [1:2] 0.683 0.683
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3449 3376
#>   ..$ envir: num [1:2] 92.5 90.4
#>   ..$ dist : num [1:2] 281 339
#>   ..$ prob : num [1:2] 0.423 0.291
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1750 1825
#>   ..$ envir: num [1:2] 61.5 73.1
#>   ..$ dist : num [1:2] 194 337
#>   ..$ prob : num [1:2] 0.635 0.294
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1298 1223
#>   ..$ envir: num [1:2] 105 132
#>   ..$ dist : num [1:2] 411 204
#>   ..$ prob : num [1:2] 0.166 0.614
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 795 795
#>   ..$ envir: num [1:2] 174 174
#>   ..$ dist : num [1:2] 82.1 82.1
#>   ..$ prob : num [1:2] 0.843 0.843
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1067 1068
#>   ..$ envir: num [1:2] 53.5 48.4
#>   ..$ dist : num [1:2] 294 56
#>   ..$ prob : num [1:2] 0.393 0.874
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3230 3231
#>   ..$ envir: num [1:2] 79 107
#>   ..$ dist : num [1:2] 95.5 65.2
#>   ..$ prob : num [1:2] 0.824 0.864
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1019 1093
#>   ..$ envir: num [1:2] 126.8 75.9
#>   ..$ dist : num [1:2] 141 352
#>   ..$ prob : num [1:2] 0.749 0.265
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3163 3087
#>   ..$ envir: num [1:2] 47.5 141.8
#>   ..$ dist : num [1:2] 144 355
#>   ..$ prob : num [1:2] 0.742 0.259
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1139 1211
#>   ..$ envir: num [1:2] 22 20.4
#>   ..$ dist : num [1:2] 157 197
#>   ..$ prob : num [1:2] 0.717 0.63
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1066 1065
#>   ..$ envir: num [1:2] 71.6 57.5
#>   ..$ dist : num [1:2] 61.9 196.4
#>   ..$ prob : num [1:2] 0.868 0.631
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3154 3154
#>   ..$ envir: num [1:2] 112 112
#>   ..$ dist : num [1:2] 148 148
#>   ..$ prob : num [1:2] 0.736 0.736
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3003 3004
#>   ..$ envir: num [1:2] 58 69.9
#>   ..$ dist : num [1:2] 63.6 319.6
#>   ..$ prob : num [1:2] 0.866 0.333
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1973 1898
#>   ..$ envir: num [1:2] 55.8 60
#>   ..$ dist : num [1:2] 281 291
#>   ..$ prob : num [1:2] 0.423 0.399
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1897 1896
#>   ..$ envir: num [1:2] 38.5 32.5
#>   ..$ dist : num [1:2] 329 231
#>   ..$ prob : num [1:2] 0.312 0.547
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1139 1139
#>   ..$ envir: num [1:2] 22 22
#>   ..$ dist : num [1:2] 157 157
#>   ..$ prob : num [1:2] 0.717 0.717
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 2927 3002
#>   ..$ envir: num [1:2] NA 29.8
#>   ..$ dist : num [1:2] 275 122
#>   ..$ prob : num [1:2] 0.437 0.782
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1213 1286
#>   ..$ envir: num [1:2] 28.5 22
#>   ..$ dist : num [1:2] 67.5 65.3
#>   ..$ prob : num [1:2] 0.861 0.864
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3168 3167
#>   ..$ envir: num [1:2] 29.4 58.5
#>   ..$ dist : num [1:2] 378 121
#>   ..$ prob : num [1:2] 0.218 0.784
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3237 3165
#>   ..$ envir: num [1:2] 42.8 32.8
#>   ..$ dist : num [1:2] 306 241
#>   ..$ prob : num [1:2] 0.364 0.522
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3234 3232
#>   ..$ envir: num [1:2] 85.5 116.5
#>   ..$ dist : num [1:2] 58.9 231.2
#>   ..$ prob : num [1:2] 0.871 0.547

#### Example (4) Sampling without replacement via sample_replace = FALSE
depths_by_container <-
  get_detection_containers_envir(
    xy = xy,
    detection_range = 425,
    coastline = dat_coast,
    envir = dat_gebco,
    sample_size = 2,
    sample_probs = calc_detection_pr,
    sample_replace = FALSE
  )
#> flapper::get_detection_containers_envir() called (@ 2023-08-29 15:42:10)... 
#> ... Implementing function checks... 
#> ... Defining detection container(s)... 
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> ... Extracting environmental conditions from detection area(s)... 
utils::str(depths_by_container)
#> List of 40
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3077 3078
#>   ..$ envir: num [1:2] 99.3 107.1
#>   ..$ dist : num [1:2] 178 261
#>   ..$ prob : num [1:2] 0.673 0.473
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 869 870
#>   ..$ envir: num [1:2] 175 167
#>   ..$ dist : num [1:2] 259.21 4.13
#>   ..$ prob : num [1:2] 0.477 0.921
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 644 645
#>   ..$ envir: num [1:2] 138 141
#>   ..$ dist : num [1:2] 54.8 209.5
#>   ..$ prob : num [1:2] 0.876 0.6
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3003 3002
#>   ..$ envir: num [1:2] 58 29.8
#>   ..$ dist : num [1:2] 63.6 122.4
#>   ..$ prob : num [1:2] 0.866 0.782
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 860 863
#>   ..$ envir: num [1:2] 145 180
#>   ..$ dist : num [1:2] 357 414
#>   ..$ prob : num [1:2] 0.256 0.162
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 946 871
#>   ..$ envir: num [1:2] 135 152
#>   ..$ dist : num [1:2] 203 255
#>   ..$ prob : num [1:2] 0.616 0.488
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1069 1068
#>   ..$ envir: num [1:2] 25.2 48.4
#>   ..$ dist : num [1:2] 228 56
#>   ..$ prob : num [1:2] 0.554 0.874
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1754 1753
#>   ..$ envir: num [1:2] 46.9 55
#>   ..$ dist : num [1:2] 163 173
#>   ..$ prob : num [1:2] 0.705 0.684
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1285 1286
#>   ..$ envir: num [1:2] 14.5 22
#>   ..$ dist : num [1:2] 214.8 65.3
#>   ..$ prob : num [1:2] 0.587 0.864
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3234 3235
#>   ..$ envir: num [1:2] 85.5 61.3
#>   ..$ dist : num [1:2] 58.9 247
#>   ..$ prob : num [1:2] 0.871 0.508
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1287 1214
#>   ..$ envir: num [1:2] 22.9 28.8
#>   ..$ dist : num [1:2] 307 214
#>   ..$ prob : num [1:2] 0.36 0.588
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1682 1755
#>   ..$ envir: num [1:2] 25.6 32.2
#>   ..$ dist : num [1:2] 192 338
#>   ..$ prob : num [1:2] 0.642 0.293
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3236 3237
#>   ..$ envir: num [1:2] 47.9 42.8
#>   ..$ dist : num [1:2] 212 306
#>   ..$ prob : num [1:2] 0.594 0.364
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3661 3588
#>   ..$ envir: num [1:2] 108 113
#>   ..$ dist : num [1:2] 125 406
#>   ..$ prob : num [1:2] 0.778 0.174
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 831 904
#>   ..$ envir: num [1:2] 118.1 76.1
#>   ..$ dist : num [1:2] 204 328
#>   ..$ prob : num [1:2] 0.614 0.314
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3231 3230
#>   ..$ envir: num [1:2] 107 79
#>   ..$ dist : num [1:2] 65.2 95.5
#>   ..$ prob : num [1:2] 0.864 0.824
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3163 3164
#>   ..$ envir: num [1:2] 47.5 40.4
#>   ..$ dist : num [1:2] 144 101
#>   ..$ prob : num [1:2] 0.742 0.817
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3155 3154
#>   ..$ envir: num [1:2] 94 112
#>   ..$ dist : num [1:2] 131 148
#>   ..$ prob : num [1:2] 0.767 0.736
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1605 1606
#>   ..$ envir: num [1:2] 47.2 36.1
#>   ..$ dist : num [1:2] 228 237
#>   ..$ prob : num [1:2] 0.555 0.532
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 2867 2866
#>   ..$ envir: num [1:2] 123 135
#>   ..$ dist : num [1:2] 173 248
#>   ..$ prob : num [1:2] 0.683 0.506
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3374 3450
#>   ..$ envir: num [1:2] 72.1 93.9
#>   ..$ dist : num [1:2] 293 400
#>   ..$ prob : num [1:2] 0.394 0.183
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1750 1824
#>   ..$ envir: num [1:2] 61.5 64.9
#>   ..$ dist : num [1:2] 194 292
#>   ..$ prob : num [1:2] 0.635 0.398
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1223 1297
#>   ..$ envir: num [1:2] 132 102
#>   ..$ dist : num [1:2] 204 273
#>   ..$ prob : num [1:2] 0.614 0.443
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 794 795
#>   ..$ envir: num [1:2] 179 174
#>   ..$ dist : num [1:2] 177.6 82.1
#>   ..$ prob : num [1:2] 0.674 0.843
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1069 994
#>   ..$ envir: num [1:2] 25.2 NA
#>   ..$ dist : num [1:2] 228 262
#>   ..$ prob : num [1:2] 0.554 0.471
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3232 3230
#>   ..$ envir: num [1:2] 116 79
#>   ..$ dist : num [1:2] 231.2 95.5
#>   ..$ prob : num [1:2] 0.547 0.824
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1018 1020
#>   ..$ envir: num [1:2] 159 83.2
#>   ..$ dist : num [1:2] 352 218
#>   ..$ prob : num [1:2] 0.264 0.58
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3162 3163
#>   ..$ envir: num [1:2] 71.9 47.5
#>   ..$ dist : num [1:2] 177 144
#>   ..$ prob : num [1:2] 0.675 0.742
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1212 1138
#>   ..$ envir: num [1:2] 28 21.6
#>   ..$ dist : num [1:2] 195 172
#>   ..$ prob : num [1:2] 0.634 0.685
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1065 1066
#>   ..$ envir: num [1:2] 57.5 71.6
#>   ..$ dist : num [1:2] 196.4 61.9
#>   ..$ prob : num [1:2] 0.631 0.868
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3080 3154
#>   ..$ envir: num [1:2] 137 112
#>   ..$ dist : num [1:2] 94.5 147.6
#>   ..$ prob : num [1:2] 0.826 0.736
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3003 3004
#>   ..$ envir: num [1:2] 58 69.9
#>   ..$ dist : num [1:2] 63.6 319.6
#>   ..$ prob : num [1:2] 0.866 0.333
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1973 1900
#>   ..$ envir: num [1:2] 55.8 64.9
#>   ..$ dist : num [1:2] 281 342
#>   ..$ prob : num [1:2] 0.423 0.286
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1897 1896
#>   ..$ envir: num [1:2] 38.5 32.5
#>   ..$ dist : num [1:2] 329 231
#>   ..$ prob : num [1:2] 0.312 0.547
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1138 1139
#>   ..$ envir: num [1:2] 21.6 22
#>   ..$ dist : num [1:2] 172 157
#>   ..$ prob : num [1:2] 0.685 0.717
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 2927 3001
#>   ..$ envir: num [1:2] NA 25.4
#>   ..$ dist : num [1:2] 275 143
#>   ..$ prob : num [1:2] 0.437 0.744
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1211 1213
#>   ..$ envir: num [1:2] 20.4 28.5
#>   ..$ dist : num [1:2] 196.6 67.5
#>   ..$ prob : num [1:2] 0.63 0.861
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3166 3165
#>   ..$ envir: num [1:2] 47.7 32.8
#>   ..$ dist : num [1:2] 136 241
#>   ..$ prob : num [1:2] 0.757 0.522
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3165 3164
#>   ..$ envir: num [1:2] 32.8 40.4
#>   ..$ dist : num [1:2] 241 101
#>   ..$ prob : num [1:2] 0.522 0.817
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3307 3233
#>   ..$ envir: num [1:2] 54.9 104.9
#>   ..$ dist : num [1:2] 417.6 45.5
#>   ..$ prob : num [1:2] 0.158 0.885

#### Example (5) Parallelise the algorithm via cl and varlist arguments
depths_by_container <-
  get_detection_containers_envir(
    xy = xy,
    detection_range = 425,
    coastline = dat_coast,
    envir = dat_gebco,
    sample_size = 2,
    sample_probs = calc_detection_pr,
    sample_replace = FALSE,
    cl = parallel::makeCluster(2L),
    varlist = c("dat_gebco", "calc_detection_pr")
  )
#> flapper::get_detection_containers_envir() called (@ 2023-08-29 15:42:12)... 
#> ... Implementing function checks... 
#> ... Defining detection container(s)... 
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> Warning: GEOS support is provided by the sf and terra packages among others
#> Warning: spgeom1 and spgeom2 have different proj4 strings
#> ... Extracting environmental conditions from detection area(s)... 
#> Error in get(name, envir = envir): object 'calc_detection_pr' not found
utils::str(depths_by_container)
#> List of 40
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3077 3078
#>   ..$ envir: num [1:2] 99.3 107.1
#>   ..$ dist : num [1:2] 178 261
#>   ..$ prob : num [1:2] 0.673 0.473
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 869 870
#>   ..$ envir: num [1:2] 175 167
#>   ..$ dist : num [1:2] 259.21 4.13
#>   ..$ prob : num [1:2] 0.477 0.921
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 644 645
#>   ..$ envir: num [1:2] 138 141
#>   ..$ dist : num [1:2] 54.8 209.5
#>   ..$ prob : num [1:2] 0.876 0.6
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3003 3002
#>   ..$ envir: num [1:2] 58 29.8
#>   ..$ dist : num [1:2] 63.6 122.4
#>   ..$ prob : num [1:2] 0.866 0.782
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 860 863
#>   ..$ envir: num [1:2] 145 180
#>   ..$ dist : num [1:2] 357 414
#>   ..$ prob : num [1:2] 0.256 0.162
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 946 871
#>   ..$ envir: num [1:2] 135 152
#>   ..$ dist : num [1:2] 203 255
#>   ..$ prob : num [1:2] 0.616 0.488
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1069 1068
#>   ..$ envir: num [1:2] 25.2 48.4
#>   ..$ dist : num [1:2] 228 56
#>   ..$ prob : num [1:2] 0.554 0.874
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1754 1753
#>   ..$ envir: num [1:2] 46.9 55
#>   ..$ dist : num [1:2] 163 173
#>   ..$ prob : num [1:2] 0.705 0.684
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1285 1286
#>   ..$ envir: num [1:2] 14.5 22
#>   ..$ dist : num [1:2] 214.8 65.3
#>   ..$ prob : num [1:2] 0.587 0.864
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3234 3235
#>   ..$ envir: num [1:2] 85.5 61.3
#>   ..$ dist : num [1:2] 58.9 247
#>   ..$ prob : num [1:2] 0.871 0.508
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1287 1214
#>   ..$ envir: num [1:2] 22.9 28.8
#>   ..$ dist : num [1:2] 307 214
#>   ..$ prob : num [1:2] 0.36 0.588
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1682 1755
#>   ..$ envir: num [1:2] 25.6 32.2
#>   ..$ dist : num [1:2] 192 338
#>   ..$ prob : num [1:2] 0.642 0.293
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3236 3237
#>   ..$ envir: num [1:2] 47.9 42.8
#>   ..$ dist : num [1:2] 212 306
#>   ..$ prob : num [1:2] 0.594 0.364
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3661 3588
#>   ..$ envir: num [1:2] 108 113
#>   ..$ dist : num [1:2] 125 406
#>   ..$ prob : num [1:2] 0.778 0.174
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 831 904
#>   ..$ envir: num [1:2] 118.1 76.1
#>   ..$ dist : num [1:2] 204 328
#>   ..$ prob : num [1:2] 0.614 0.314
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3231 3230
#>   ..$ envir: num [1:2] 107 79
#>   ..$ dist : num [1:2] 65.2 95.5
#>   ..$ prob : num [1:2] 0.864 0.824
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3163 3164
#>   ..$ envir: num [1:2] 47.5 40.4
#>   ..$ dist : num [1:2] 144 101
#>   ..$ prob : num [1:2] 0.742 0.817
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3155 3154
#>   ..$ envir: num [1:2] 94 112
#>   ..$ dist : num [1:2] 131 148
#>   ..$ prob : num [1:2] 0.767 0.736
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1605 1606
#>   ..$ envir: num [1:2] 47.2 36.1
#>   ..$ dist : num [1:2] 228 237
#>   ..$ prob : num [1:2] 0.555 0.532
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 2867 2866
#>   ..$ envir: num [1:2] 123 135
#>   ..$ dist : num [1:2] 173 248
#>   ..$ prob : num [1:2] 0.683 0.506
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3374 3450
#>   ..$ envir: num [1:2] 72.1 93.9
#>   ..$ dist : num [1:2] 293 400
#>   ..$ prob : num [1:2] 0.394 0.183
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1750 1824
#>   ..$ envir: num [1:2] 61.5 64.9
#>   ..$ dist : num [1:2] 194 292
#>   ..$ prob : num [1:2] 0.635 0.398
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1223 1297
#>   ..$ envir: num [1:2] 132 102
#>   ..$ dist : num [1:2] 204 273
#>   ..$ prob : num [1:2] 0.614 0.443
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 794 795
#>   ..$ envir: num [1:2] 179 174
#>   ..$ dist : num [1:2] 177.6 82.1
#>   ..$ prob : num [1:2] 0.674 0.843
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1069 994
#>   ..$ envir: num [1:2] 25.2 NA
#>   ..$ dist : num [1:2] 228 262
#>   ..$ prob : num [1:2] 0.554 0.471
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3232 3230
#>   ..$ envir: num [1:2] 116 79
#>   ..$ dist : num [1:2] 231.2 95.5
#>   ..$ prob : num [1:2] 0.547 0.824
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1018 1020
#>   ..$ envir: num [1:2] 159 83.2
#>   ..$ dist : num [1:2] 352 218
#>   ..$ prob : num [1:2] 0.264 0.58
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3162 3163
#>   ..$ envir: num [1:2] 71.9 47.5
#>   ..$ dist : num [1:2] 177 144
#>   ..$ prob : num [1:2] 0.675 0.742
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1212 1138
#>   ..$ envir: num [1:2] 28 21.6
#>   ..$ dist : num [1:2] 195 172
#>   ..$ prob : num [1:2] 0.634 0.685
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1065 1066
#>   ..$ envir: num [1:2] 57.5 71.6
#>   ..$ dist : num [1:2] 196.4 61.9
#>   ..$ prob : num [1:2] 0.631 0.868
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3080 3154
#>   ..$ envir: num [1:2] 137 112
#>   ..$ dist : num [1:2] 94.5 147.6
#>   ..$ prob : num [1:2] 0.826 0.736
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3003 3004
#>   ..$ envir: num [1:2] 58 69.9
#>   ..$ dist : num [1:2] 63.6 319.6
#>   ..$ prob : num [1:2] 0.866 0.333
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1973 1900
#>   ..$ envir: num [1:2] 55.8 64.9
#>   ..$ dist : num [1:2] 281 342
#>   ..$ prob : num [1:2] 0.423 0.286
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1897 1896
#>   ..$ envir: num [1:2] 38.5 32.5
#>   ..$ dist : num [1:2] 329 231
#>   ..$ prob : num [1:2] 0.312 0.547
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1138 1139
#>   ..$ envir: num [1:2] 21.6 22
#>   ..$ dist : num [1:2] 172 157
#>   ..$ prob : num [1:2] 0.685 0.717
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 2927 3001
#>   ..$ envir: num [1:2] NA 25.4
#>   ..$ dist : num [1:2] 275 143
#>   ..$ prob : num [1:2] 0.437 0.744
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 1211 1213
#>   ..$ envir: num [1:2] 20.4 28.5
#>   ..$ dist : num [1:2] 196.6 67.5
#>   ..$ prob : num [1:2] 0.63 0.861
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3166 3165
#>   ..$ envir: num [1:2] 47.7 32.8
#>   ..$ dist : num [1:2] 136 241
#>   ..$ prob : num [1:2] 0.757 0.522
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3165 3164
#>   ..$ envir: num [1:2] 32.8 40.4
#>   ..$ dist : num [1:2] 241 101
#>   ..$ prob : num [1:2] 0.522 0.817
#>  $ :'data.frame':	2 obs. of  4 variables:
#>   ..$ cell : num [1:2] 3307 3233
#>   ..$ envir: num [1:2] 54.9 104.9
#>   ..$ dist : num [1:2] 417.6 45.5
#>   ..$ prob : num [1:2] 0.158 0.885