zctas {tigris} | R Documentation |
Download a Zip Code Tabulation Area (ZCTA) shapefile into R
Description
ZIP Code Tabulation Areas (ZCTAs) are generalized areal representations of United States Postal Service (USPS) ZIP Code service areas. Please see the link provided for information on how the Census Bureau creates ZCTAs, and for important information on the differences between ZCTAs and ZIP Codes.
Usage
zctas(cb = FALSE, starts_with = NULL, year = NULL, state = NULL, ...)
Arguments
cb |
If cb is set to TRUE, download a generalized (1:500k) ZCTA file. Defaults to FALSE (the most detailed TIGER/Line file). A warning: the detailed TIGER/Line ZCTA file is massive (around 502MB unzipped), and the generalized version is also large (64MB zipped). Be prepared for this especially if you have a slower internet connection. |
starts_with |
Character vector specifying the beginning digits of the
ZCTAs you want to return. For example, supplying the argument
|
year |
the data year; defaults to 2022 |
state |
the state for which you are requesting data; only available for 2000 (TIGER/Line and CB shapefiles) and 2010 (TIGER/Line shapefiles only) |
... |
arguments to be passed to internal function |
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://www.census.gov/programs-surveys/geography/guidance/geo-areas/zctas.html
Other general area functions:
block_groups()
,
blocks()
,
counties()
,
county_subdivisions()
,
places()
,
pumas()
,
school_districts()
,
states()
,
tracts()
Examples
## Not run:
# Example: get ZCTAs that intersect the Memphis, TN urbanized area
library(tigris)
zcta1 <- zctas(cb = TRUE, starts_with = c("37", "38", "72"))
uas <- urban_areas()
memphis_ua <- uas[grep("Memphis", uas$NAME10), ]
mem_zcta <- zcta1[memphis_ua, ]
plot(mem_zcta$geometry)
## End(Not run)