Skip to contents

This function runs anime::anime() to match source features to target features based on angle and distance tolerances. The matched source attribute(s) are then aggregated (sum, max, mean, etc.) and joined back to the target data.

Usage

anime_join(
  source_data,
  target_data,
  attribute,
  new_name,
  agg_fun = sum,
  weights,
  angle_tolerance = 35,
  distance_tolerance = 15
)

Arguments

source_data

An sf object representing the source data.

target_data

An sf object representing the target data.

attribute

A character string, the name of the source attribute to aggregate.

new_name

A character string for the output column name in the returned data frame.

agg_fun

A function used to aggregate the matched values (e.g., sum, mean, max). Defaults to sum.

weights

A character vector of column names in the source data to be used as weights. (For example, "target_weighted").

angle_tolerance

A numeric value for angular tolerance used by anime. Defaults to 35.

distance_tolerance

A numeric value for distance tolerance used by anime. Defaults to 15.

Value

A data.frame (or tibble) containing:

  • id: The original id from target_data.

  • new_name: The aggregated attribute (named according to new_name).

Examples

if (FALSE) { # \dontrun{
  result = anime_join(
    source_data      = my_source_sf,
    target_data      = my_target_sf,
    attribute        = "population",
    new_name         = "pop_sum",
    agg_fun          = sum,
    weights          = "target_weighted",
    angle_tolerance  = 35,
    distance_tolerance = 15
  )
} # }