Takes a data frame containing mapping information of trees in one or more stands and returns neighborhood information for all trees or a set of user-provided coordinates.

neighborhoods(mapping, dbh_data = NULL, stands = "all", radius, coords = NULL)

Arguments

mapping

Data frame containing tree coordinates.

dbh_data

Data frame containing a single dbh measurement for each tree id in mapping. Must have columns tree_id and dbh - any additional columns will be ignored by this function.

stands

Vector of names of stands for which neighborhoods are desired.

radius

Numeric vector describing neighborhood radius in meters.

coords

Data frame containing coordinates for which neighborhoods are desired. Data frame should contain three columns in the following order - location ids, x-coordinates, y-coordinates. Column names are unimportant.

Value

Neighborhood information for all focal trees in mapping or, if coords is provided, for all locations defined by coordinates.

Details

This function requires dbh information for each tree in mapping in order to return the dbh of each neighboring tree in each neighborhood. If mapping contains no dbh data or it is desired to use different dbh data (mapping datasets usually contain dbh at initial measurement, which could be outdated), the argument dbh_data must be specified.

This function returns a neighborhoods object, which is a data frame where each focal tree or user-provided set of coordinates appears on multiple lines with each line containing information on one of the trees in its neighborhood. Specifically, each line contains the ID number (id_comp), species identity (sps_comp), size (dbh_comp and abh_comp), and distance from the neighborhood center (prox) of the neighbor tree. The neighborhoods object can be passed into a number of other functions in forestexplorR, including neighborhood_summary and site_by_species.

Examples

# Create neighborhoods for trees in mapping nbhds <- neighborhoods(mapping, stands = c("AB08", "PP17"), radius = 10) # Create neighborhoods for trees in mapping using more up-to-date dbh data library(dplyr) tree_dbhs <- tree %>% filter(stand_id == "AB08") %>% group_by(tree_id) %>% arrange(year) %>% summarize(dbh = dbh[n()]) nbhds <- neighborhoods(mapping, dbh_data = tree_dbhs, stands = "AB08", radius = 10) # Create neighborhoods for user-provided coordinates locations <- data.frame( loc_id = paste("A", 1:81, sep = ""), x_coord = rep(seq(10, 90, 10), times = 9), y_coord = rep(seq(10, 90, 10), each = 9)) nbhds <- neighborhoods(mapping, stands = "AB08", radius = 10, coords = locations)