| Title: | Block Assignment Files |
|---|---|
| Description: | Download and read US Census Bureau data relationship files. Provides support for cleaning and using block assignment files since 2010, as described in <https://www.census.gov/geographies/reference-files/time-series/geo/block-assignment-files.html>. Also includes support for working with block equivalency files, used for years outside of decennial census years. |
| Authors: | Christopher T. Kenny [aut, cre] (ORCID: <https://orcid.org/0000-0002-9386-6860>), Cory McCartan [ctb] (ORCID: <https://orcid.org/0000-0002-6251-669X>) |
| Maintainer: | Christopher T. Kenny <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.0.4 |
| Built: | 2026-05-31 06:20:48 UTC |
| Source: | https://github.com/christopherkenny/baf |
Download Block Assignment Files (BAF) from the Census Bureau
baf( state, year = 2020, geographies = NULL, cache_to = baf_download_path(), overwrite = FALSE )baf( state, year = 2020, geographies = NULL, cache_to = baf_download_path(), overwrite = FALSE )
state |
state to download data for. |
year |
year to download data for. Default is |
geographies |
geography types to download. Default is |
cache_to |
directory name to save the downloaded data. Default is |
overwrite |
Should the data be re-downloaded? Default is |
a list of dplyr::tibbles for each geography type
baf('DE', 2020)baf('DE', 2020)
Download a file
baf_download(url, path, overwrite = FALSE, quiet = FALSE)baf_download(url, path, overwrite = FALSE, quiet = FALSE)
url |
a URL |
path |
a file path |
overwrite |
should the file at path be overwritten if it already exists? Default is FALSE. |
quiet |
should output and progress bar be suppressed? |
a path to the downloaded file, invisibly
tf <- tempfile(fileext = '.zip') ex <- 'https://www2.census.gov/geo/docs/maps-data/data/baf2020/BlockAssign_ST01_AL.zip' baf_download(url = ex, path = tf)tf <- tempfile(fileext = '.zip') ex <- 'https://www2.census.gov/geo/docs/maps-data/data/baf2020/BlockAssign_ST01_AL.zip' baf_download(url = ex, path = tf)
baf filesGet download location for baf files
baf_download_path()baf_download_path()
a path
baf_download_path()baf_download_path()
Clean Block Assignment Files
clean_bafs(bafs, state = NULL)clean_bafs(bafs, state = NULL)
bafs |
list of block assignment files, named by type |
state |
if provided, adds the first two digits of the state FIPS to each code |
a tibble with two columns
GEOID: block GEOIDs
target: output GEOIDs for the target geography
data('example_baf') |> clean_bafs('WA')data('example_baf') |> clean_bafs('WA')
list of tibbles with 1,562 rows each
data('example_baf')data('example_baf')
tibble with state identifying information
data('example_baf')data('example_baf')