read_ipums_sf | R Documentation |
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 )
shape_file |
Filepath to one or more .shp files, a .zip file from an IPUMS extract or a path to an unzipped folder. |
shape_layer |
For .zip extracts with multiple datasets, the name of the
shape files to load. Accepts a character vector specifying the file name, or
|
vars |
Which variables in the shape file's data to keep (NULL the default keeps all) |
encoding |
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). |
bind_multiple |
If |
add_layer_var |
Whether to add a variable named |
verbose |
I |
read_ipums_sf
returns a sf object and read_ipums_sp
returns
a SpatialPolygonsDataFrame.
Other ipums_read:
read_ipums_micro_chunked()
,
read_ipums_micro_yield()
,
read_ipums_micro()
,
read_nhgis()
,
read_terra_area()
,
read_terra_micro()
,
read_terra_raster()
shape_file <- ipums_example("nhgis0008_shape_small.zip") # If sf package is availble, can load as sf object if (require(sf)) { sf_data <- read_ipums_sf(shape_file) } # If sp package is available, can load as SpatialPolygonsDataFrame if (require(sp) && require(rgdal)) { sp_data <- read_ipums_sp(shape_file) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.