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.
zctas(cb = FALSE, starts_with = NULL, year = NULL, state = NULL, ...)
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.
Character vector specifying the beginning digits of the
ZCTAs you want to return. For example, supplying the argument
starts_with = c("75", "76")
will return only those ZCTAs that begin
with 75 or 76. Defaults to NULL, which will return all ZCTAs in the US.
the data year; defaults to 2024
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 load_tiger
, which is not exported. See 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 to FALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults to TRUE
.
keep_zipped_shapefile
If set to TRUE
, do not delete zipped shapefile (stored in temporary directory or TIGRIS_CACHE_DIR
depending on the configuration of global option "tigris_use_cache"
). Defaults to FALSE
.
refresh
Whether to re-download cached shapefiles (TRUE
or FALSE
) . The default is either FALSE
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 class bbox
, or a length-4 vector of format c(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input to filter_by
will be returned.
protocol
Character string specifying the protocol to use for downloading files. Options are "ftp" or "http" (default). If "ftp", the URL will be modified to use FTP instead of HTTPS.
timeout
Integer specifying the timeout in seconds for download operations if protocol is "ftp". Defaults to 1800 (30 minutes) to handle large files.
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()
if (FALSE) {
# 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)
}
Run the code above in your browser using DataLab