Compute overlap allocation ratios between polygons
get_overlap_allocation.RdCalculates the proportion of each fine-grain polygon (from_geom) overlapping with coarse-grain polygons (to_geom), returning allocation ratios for crosswalking data. Use to allocate values between geographies based on area overlap.
Usage
get_overlap_allocation(
overlap_sf,
from_geom,
to_geom,
from_key,
to_key,
method = "area",
overlap_tol,
preserve_representatives = FALSE
)Arguments
- overlap_sf
sf object. Subset of from_geom polygons to allocate.
- from_geom
sf object. Fine-grain geometry to convert from.
- to_geom
sf object. Coarse-grain geometry to convert to.
- from_key
character vector. Key columns for from_geom.
- to_key
character vector. Key columns for to_geom.
- method
character(1). Allocation method. Only 'area' supported. Default 'area'.
- overlap_tol
numeric(1). Cutoff for accepted overlaps (e.g., 0.05).
- preserve_representatives
logical(1). If TRUE, keeps at least one representative per from_geom. Default FALSE.
Value
data.table. Overlap allocation ratios with keys and overlap_ratio. Columns:
from_key <character/integer> — key for fine-grain geometry
to_key <character/integer> — key for coarse-grain geometry
overlap_ratio
— proportion of from_geom area overlapping to_geom Rows: one per overlap pair. Keys: (from_key, to_key).
Details
Transforms input geometries to equal area projection for accurate area calculation.
Computes intersection polygons and their areas.
Calculates overlap ratio for each from_geom as intersection area divided by from_geom area.
Removes slivers and adjusts overlap ratios based on provided tolerance.
If preserve_representatives is TRUE, ensures at least one representative per from_geom.
Returns a data.table with keys and overlap_ratio; does not modify by reference.
Assumes valid sf geometries and keys; errors if empty or invalid.
See also
get_xwalk_sfx_to_sfy
Other ACS utilities:
get_acs_bg_counts(),
get_acs_bg_counts_base(),
get_puma_ids(),
get_pumas(),
get_tracts_puma_xwalk(),
get_xwalk_sfx_to_sfy(),
load_xwalk()