shp_to_Rpolygons: shp_to_Rpolygons

Description Usage Arguments Value Examples

Description

Brings in a shapefile (from a directory on the computer) as a SpatialPolygonsDataFrame with a data.table as the data attributes.

Usage

1
shp_to_Rpolygons(shp_dir, shp_layer, id_field, all_data = T)

Arguments

shp_dir

The directory where your shapefile is

shp_layer

The name of the shapefile (ex: "census_tracts"), with no .shp or any other extension

id_field

Character string of the column that is the primary key (what defines polygons as being different from one another) in the shapefile. If a field that is not a primary key is provided, the polygons will be collapsed such that there will be 1 polygon object (possibly multi-part) for each of the primary keys you have identified, but the rest of the data table will no longer attach to the shapefile.

all_data

Logical; Whether you want the rest of the data attributes (other than the id_field provided) to remain in the @data slot of the SpatialPolygonsDataFrame.

Value

A SpatialPolygonsDataFrame with a data.table

Examples

1
shp_to_Rpolygons("C:/Users/username/Documents/spatial_data/","shapfile_name","fipscode")

RebeccaStubbs/woodson documentation built on May 9, 2019, 9:37 a.m.