Skip to contents

This assumes unique keys defined in input and output shapes through column grouping and outputs a mapping table between input and output groups. The input is related to the output by containment. I.e. the result will be where the input is wholly contained within the output shape

Usage

getContainedIn(
  inputShape,
  outputShape,
  inputVars = inputShape %>% dplyr::groups(),
  outputVars = outputShape %>% dplyr::groups(),
  suffix = c(".x", ".y")
)

Arguments

inputShape

- a sf containing points of interest (or shapes)

outputShape

- a sf containing polygons to locate the input in.

inputVars

- defines the columns of the input that you want to retain (as a dplyr::vars(...) list). This grouping should uniquely identify the row. If not present will use the current grouping of inputShape.

outputVars

- defines the columns of the output that you want to retain (as a dplyr::vars(...) list). This grouping should uniquely identify the row. If not present will use the current grouping of outputShape.

suffix

- the suffix of any duplicated columns as per dplyr::inner_join()

Value

- a mapping as a dataframe relating the `inputVars` columns and `outputVars` columns

Examples

# find the hospitals in a given area.
mapping = getContainedIn(
  inputShape = arear::surgecapacity,
  outputShape = arear::ukcovidmap(),
  inputVars = dplyr::vars(hospitalId),
  outputVars = dplyr::vars(code)
)
#> Spherical geometry (s2) switched off
#> caching item: ~/.cache/arear/cached-87104ae5fea70bf68227e23cc93f9b65-c0dff8cf33089ce431bf22abf3b7d4cf.rda
#> although coordinates are longitude/latitude, st_contains assumes that they are
#> planar