Split values observed on a larger geography across a smaller geography after
first matching each row of to to a row of from. This is commonly used to
distribute precinct-level election totals to blocks.
geo_estimate_down(from, to, wts, value, method = "center", epsg = 3857)Larger geography level containing the observed values.
Smaller geography level to estimate onto.
Numeric vector of length nrow(to). Used to allocate each matched
value across rows of to. Defaults to 1, which splits evenly within each
matched group.
Numeric vector of length nrow(from) containing the values to
split downward. Defaults to 1.
Matching method passed to geo_match().
numeric EPSG code to planarize to. Default is 3857.
numeric vector of length nrow(to) with estimated values
If all weights for a matched group are zero, the function falls back to equal
allocation within that group. Rows in to that do not match any row of
from receive 0.
library(dplyr)
set.seed(1)
data(checkerboard)
counties <- checkerboard |>
group_by(id <= 32) |>
summarize(geometry = sf::st_union(geometry)) |>
mutate(pop = c(100, 200))
geo_estimate_down(from = counties, to = checkerboard, value = counties$pop)
#> Warning: Planarizing skipped. `x` missing CRS.
#> Warning: Planarizing skipped. `x` missing CRS.
#> [1] 6.250 6.250 6.250 6.250 6.250 6.250 6.250 6.250 6.250 6.250 6.250 6.250
#> [13] 6.250 6.250 6.250 6.250 6.250 6.250 6.250 6.250 6.250 6.250 6.250 6.250
#> [25] 6.250 6.250 6.250 6.250 6.250 6.250 6.250 6.250 3.125 3.125 3.125 3.125
#> [37] 3.125 3.125 3.125 3.125 3.125 3.125 3.125 3.125 3.125 3.125 3.125 3.125
#> [49] 3.125 3.125 3.125 3.125 3.125 3.125 3.125 3.125 3.125 3.125 3.125 3.125
#> [61] 3.125 3.125 3.125 3.125