blocks {tigris} | R Documentation |
Download a Census block shapefile into R
Description
Description from the US Census Bureau (see link for source): Census blocks are statistical areas bounded on all sides by visible features, such as streets, roads, streams, and railroad tracks, and by non-visible boundaries such as city, town, township, and county limits, and short line-of-sight extensions of streets and roads. Generally, census blocks are small in area; for example, a block in a city. Census blocks in suburban and rural areas may be large, irregular and bounded by a variety of features, such as roads, streams, and/or transmission line rights-of-way. In remote areas census blocks may encompass hundreds of square miles. Census blocks cover all territory in the United States, Puerto Rico, and the Island areas. Blocks do not cross the boundaries of any entity for which the Census Bureau tabulates data.
Usage
blocks(state, county = NULL, year = NULL, ...)
Arguments
state |
The two-digit FIPS code (string) of the state you want. Can also be state name or state abbreviation. |
county |
The three-digit FIPS code (string) of the county you'd like to subset for, or a vector of FIPS codes if you desire multiple counties. Can also be a county name or vector of names. |
year |
the data year; defaults to 2022 |
... |
arguments to be passed to internal function |
Details
This function will download an entire block shapefile for a selected state into R, and optionally subset by county. A warning: Census block shapefiles are often very large, especially for large states - for example, the block file for Texas is 462MB zipped! If you have a slow or unreliable internet connection, or insufficient memory, this may prove burdensome given that you have to first download by state and then subset.
Additional Arguments
Additional arguments that can be passed in ...
are:
-
class
Desired class of return object:"sf"
(the default) or"sp"
. sp classes should be considered deprecated as of tigris version 2.0, but legacy support is still available. -
progress_bar
If set toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
or the value of global option"tigris_refresh"
if it is set. Specifying this argument will override the behavior set in"tigris_refresh"
global option. -
filter_by
Geometry used to filter the output returned by the function. Can be an sf object, an object of classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_by
will be returned.
See Also
https://www2.census.gov/geo/pdfs/maps-data/data/tiger/tgrshp2020/TGRSHP2020_TechDoc.pdf
Other general area functions:
block_groups()
,
counties()
,
county_subdivisions()
,
places()
,
pumas()
,
school_districts()
,
states()
,
tracts()
,
zctas()
Examples
## Not run:
# Simple example using Rose Island, American Samoa
# Be careful with Census blocks for states!
library(tigris)
library(leaflet)
rose_island <- blocks(state = "AS", county = "Rose Island")
leaflet(rose_island) %>%
addTiles() %>%
addPolygons()
## End(Not run)