Learn R Programming

tigris (version 0.1)

zctas: 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, detailed = TRUE, ...)

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 al
starts_with
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
detailed
(deprecated) Setting detailed to FALSE returns a 1:500k cartographic boundary file. This parameter will be removed in a future release.
...
arguments to be passed to the underlying `load_tiger` function, which is not exported. Options include refresh, which specifies whether or not to re-download shapefiles (defaults to FALSE), and year, the year for w

See Also

https://www.census.gov/geo/reference/zctas.html Other general area functions: block_groups; blocks; counties; places; pumas; school_districts; states; tracts

Examples

Run this code
# Example: get ZCTAs that intersect the Memphis, TN urbanized area

library(tigris)
library(rgeos)
library(sp)

df <- zctas(cb = TRUE, starts_with = c("37", "38", "72"))

uas <- urban_areas()

memphis_ua <- uas[grep("Memphis", uas$NAME10), ]

mem_zcta <- df[as.vector(gIntersects(df, memphis_ua, byid = TRUE)), ]

plot(mem_zcta)

Run the code above in your browser using DataLab