Variant of block2prec() that matches blocks to precincts separately within
each county. This helps avoid cross-county mismatches when county boundaries
and census blocks do not line up cleanly.
block2prec_by_county(block_table, precinct, precinct_county_fips, epsg = 3857)Block table, usually from create_block_table().
sf object of target precinct shapes.
Name of the county identifier column in precinct.
numeric EPSG code to planarize to. Default is 3857.
dataframe with one row per row of precinct, ordered to align with
the input precinct object.
if (FALSE) { # \dontrun{
# Need Census API
data(towns)
towns$fips <- '087'
block <- create_block_table('NY', 'Rockland')
block2prec_by_county(block, towns, 'fips')
} # }