geo_match: Match Across Geographic Layers

View source: R/match.R

geo_matchR Documentation

Match Across Geographic Layers

Description

Match Across Geographic Layers

Usage

geo_match(
  from,
  to,
  method = "center",
  by = NULL,
  tiebreaker = TRUE,
  epsg = 3857
)

Arguments

from

smaller geographic level to match up from

to

larger geographic level to be matched to

method

string from 'center', 'centroid', 'point', 'circle', or 'area' for matching method

by

A character vector to match by. One element if both from and to share the subsetting column name. One element with a name (for from) and one element (for to).

tiebreaker

Should ties be broken? boolean. If FALSE, precincts with no matches get value -1 and precincts with multiple matches get value -2.

epsg

numeric EPSG code to planarize to. Default is 3857.

Details

Methods are as follows:

  • centroid: matches each element of from to the to entry that the geographic centroid intersects

  • center: very similar to centroid, but it matches an arbitrary center point within from if the centroid of from is outside the bounds of from. (This happens for non-convex shapes only).

  • point: matches each element of from to the to entry that the "point on surface" intersects.

  • circle: matches each element of from to the to entry that the centroid of the maximum inscribed circle intersects

  • area: matches each element of from to the to element which has the largest area overlap

Value

Integer Vector of matches length(to) with values in 1:nrow(from)

Examples

library(dplyr)
data(checkerboard)
counties <- sf::st_as_sf(as.data.frame(rbind(
  sf::st_union(checkerboard %>% filter(i < 4)),
  sf::st_union(checkerboard %>% filter(i >= 4))
)))

geo_match(from = checkerboard, to = counties)
geo_match(from = checkerboard, to = counties, method = 'area')

christopherkenny/geomander documentation built on Feb. 18, 2024, 7:58 p.m.