Skip to contents

Get a shapefile from a local folder, optionally crop it by a bounding box, and return it as a sf object getLayer is used within TADA_addPolys and TADA_addPoints

Usage

getLayer(layerfilepath, bbox = NULL)

Arguments

layerfilepath

Local path to the .shp file for the layer

bbox

A bounding box from the sf function st_bbox; used to filter the query results. Optional; defaults to NULL.

Value

sf object containing the layer

Examples

if (FALSE) { # \dontrun{
# Load example dataset
data(Data_6Tribes_5y_Harmonized)
# Get the bounding box of the data
bbox <- sf::st_bbox(c(xmin = min(Data_6Tribes_5y_Harmonized$TADA.LongitudeMeasure), ymin = min(Data_6Tribes_5y_Harmonized$TADA.LatitudeMeasure), xmax = max(Data_6Tribes_5y_Harmonized$TADA.LongitudeMeasure), ymax = max(Data_6Tribes_5y_Harmonized$TADA.LatitudeMeasure)), crs = sf::st_crs(Data_6Tribes_5y_Harmonized))
# Get the American Indian Reservations feature layer, filtered by the bounding box for the Data_6Tribes_5y_Harmonized example dataset
layerfilepath <- "extdata/AmericanIndian.shp"
getLayer(layerfilepath, bbox)
} # }