Skip to contents

Calculate the 'in-sea' distance between polygons

Usage

calc_in_sea_distance(
  cellsize = 1000,
  bioregion,
  areas,
  units = "km",
  crs = paste0("+proj=aeqd +lon_0=", st_coordinates(st_centroid(bioregion))[1, 1],
    " +lat_0=", st_coordinates(st_centroid(bioregion))[1, 2],
    " +datum=WGS84 +units=m +no_defs")
)

Arguments

cellsize

numeric with target cellsize in meters of hexagonal cells the distance between opposite edges. The edge length is cellsize/sqrt(3))

bioregion

sf polygon of the study area (i.e. the sea!)

areas

sf polygons among which to calculate distances. e.g. protected areas

units

character string for output distance matrix. Either "m" or "km" (by default).

crs

target coordinate reference system: object of class crs, or input string for st_crs

Value

distance matrix

Examples

if (FALSE) { # \dontrun{
require(MarConsNetData)
bioregion <- data_bioregion()
areas <- data_CPCAD_areas(bioregion,zones=FALSE) |>
  dplyr::mutate(area=sf::st_area(geoms))
distkm <- calc_in_sea_distance(cellsize=100000,bioregion,areas)
} # }