Description Usage Arguments Author(s) Examples
View source: R/AttributePlots.R
Attributes TDat_LMF with spatial attribute (i.e. allotment, watershed unit, etc)
1 2 | AttributePlots(TDat_LMF, shapefile_name, shapefile_path,
attribute_title, attribute_name)
|
TDat_LMF |
Combined TerrADat and LMF dataframe. Returned from Combine_AIM_LMF() |
shapefile_name |
name of the shapefile you are intersecting with the dataframe (either layer name if in a .gdb or shapefile name if in folder (no extension)) |
shapefile_path |
location of your shapefile. Full .gdb extension if shapefile is a layer in a geodatabase. |
attribute_title |
name or names of the attribute in the spaefile that you want added as field in TDat_LMF (i.e. "Allot_name", or c("Allot_name", "Allot_no", "Pasture_name") |
attribute_name |
optional. If included, will subset all data by this feature (i.e. the name of a specific allotment) |
Rachel Burke, ecologist/analyst @ Jornada
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | TDat_LMF_Attributed <- AttributePlots(TDat_LMF, shapefile_name, shapefile_path,
attribute_title, attribute_name)
## The function is currently defined as
function (TDat_LMF, shapefile_name, shapefile_path, attribute_title, attribute_name)
{
if(missing(attribute_name)){
#if attribute_name is included, will subset data to attribute
#(i.e. 1 or multiple allotments)
attribute_name <- NA
}
# Match coordinate reference systems for intersection
projection <- sf::st_crs("+proj=longlat +datum=NAD83")
# Join by PrimaryKey to get GPS coordinates for species indicators entries
# TDat_LMF is output of Combine_AIM_LMF
coordinates <- TDat_LMF
# Convert Terradat data into "simple feature" object class for spatial reference. Not removing any NA or entries without coordinates.
TDat_LMF_Spatial <- sf::st_as_sf(TDat_LMF, coords = c("Longitude_NAD83", "Latitude_NAD83"), na.fail = FALSE, remove = FALSE, crs = projection)
##-----------------------------------
# Load in shapefiles and intersect with data (include AND exclude data in sf)
##-----------------------------------
# Read in shapefiles
shapefile <- sf::st_read(dsn = shapefile_path, layer = shapefile_name)
shapefile <- sf::st_transform(shapefile, crs = projection)
#Simplify shapefile to just the attributes we want
shapefile <- shapefile
# Intersect shapefile with plots to get attributed
TDat_LMF_Attributed <- sf::st_intersection(TDat_LMF_Spatial, sf::st_make_valid(shapefile))
return(TDat_LMF_Attributed)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.