treeMap: treeMap: creates plot of trees by status and size

Description Usage Value Examples

View source: R/treeMap.R

Description

This function converts tree distance and azimuth values to coordinates and plots the coordinates of live or dead trees. Trees are color coded by status, and size is relative to DBH. Works best with data.frame derived from joinLocEvent and joinTreeData, then cleaned up with treeMapPrep(). Requires a data.frame with the following fields: Plot_Name, Tree_Number_MIDN, Distance, Azimuth, Orientation, Status_ID (n=7), DBH, x, and y.

Usage

1

Value

Returns a map of trees on a given plot. Trees are color coded by status, with AB= Alive Broken, AF= Alive Fallen, AL= Alive Leaning, AS= Alive Standing, DB= Dead Broken, DL= Dead Leaning, and DS= Dead Standing. The size of the circle is relative to the DBH of the tree. The plot is relative to the plot Orientation, which is North (360 degrees) on flat lands, and upslope on slopes.

Examples

 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
importData()
# Compile data to have the fields that feed into the treeMap and treeMapPrep functions
park_plots<-joinLocEvent(from=2015, to=2015, output='verbose')[,c('Event_ID','Orientation')]
tree_data<-joinTreeData(from=2015, to=2015)
tree_data2<-merge(tree_data,park_plots,by="Event_ID",all.x=T)

# Select a plot to map
tree_plot<-tree_data2 %>% filter(Plot_Name=='RICH-064') %>% droplevels()
treeMap(tree_plot)

# Or create a list of plots to iterate through and save each to a .pdf file
#--- Create function for plotting and saving maps
saveTreeMaps<-function(path,df){
  plotname<-as.character(unique(df$Plot_Name))
  pdf(file=paste0(path, plotname,".pdf"))
  treeMap(df)
  dev.off()
}

#--- Create list of plots to iterate through
plots<-as.character(unique(tree_data2$Plot_Name)) #list of plots to iterate
filepath = c('./treeMap_output/')

#--- Loop through list of plots
for (i in 1:length(plots)){
  df <- tree_data2 %>% filter(Plot_Name==plots[[i]]) %>% droplevels()
  saveTreeMaps(path=filepath,df=df)
}

KateMMiller/forestMIDNarch documentation built on April 9, 2021, 3:50 p.m.