Reads the boundary files from an IPUMS extract into R as simple features (sf) objects or SpatialPolygonsDataFrame (sp) objects.

read_ipums_sf(shape_file, shape_layer = NULL, vars = NULL,
  encoding = NULL, bind_multiple = TRUE, add_layer_var = NULL,
  verbose = TRUE)

read_ipums_sp(shape_file, shape_layer = NULL, vars = NULL,
  encoding = NULL, bind_multiple = TRUE, add_layer_var = NULL,
  verbose = TRUE)



Filepath to one or more .shp files, a .zip file from an IPUMS extract or a path to an unzipped folder.


For .zip extracts with multiple datasets, the name of the shape files to load. Accepts a character vector specifying the file name, or dplyr_select_style conventions. Can load multiple shape files, which will be combined.


Which variables in the shape file's data to keep (NULL the default keeps all)


The text encoding to use when reading the shape file. Typically the defaults should read the data correctly, but for some extracts you may need to set them manually, but if funny characters appear in your data, you may need to. For microdata projects, the default NULL will look for a .cpg file to determine the encoding and if none is available, it will default to latin1. The NHGIS and the IPUMS Terra functions specify the encoding for those projects (latin1 and UTF-8 respectively).


If TRUE, will combine multiple shape files found into a single object.


Whether to add a variable named layer that indicates which shape_layer the data came from. NULL, the default, uses TRUE if more than 1 layer is found, and FALSE otherwise.


I TRUE, will report progress information


read_ipums_sf returns a sf object and read_ipums_sp returns a SpatialPolygonsDataFrame.

See also


shape_file <- ipums_example("") # If sf package is availble, can load as sf object if (require(sf)) { sf_data <- read_ipums_sf(shape_file) }
#> options: ENCODING=latin1 #> Reading layer `US_pmsa_1990' from data source `C:\Users\burkx031\AppData\Local\Temp\RtmpgnQu91\file1ee448e474ed\US_pmsa_1990.shp' using driver `ESRI Shapefile' #> Simple feature collection with 71 features and 8 fields #> geometry type: MULTIPOLYGON #> dimension: XY #> bbox: xmin: -2336182 ymin: -1247086 xmax: 2075339 ymax: 1476544 #> epsg (SRID): NA #> proj4string: +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=37.5 +lon_0=-96 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs
# If sp package is available, can load as SpatialPolygonsDataFrame if (require(sp) && require(rgdal)) { sp_data <- read_ipums_sp(shape_file) }
#> OGR data source with driver: ESRI Shapefile #> Source: "C:\Users\burkx031\AppData\Local\Temp\RtmpgnQu91\file1ee47d662ea4", layer: "US_pmsa_1990" #> with 71 features #> It has 8 fields