stemMappingExtension_square: Extend stem mapping to a target area and shape.

View source: R/stemMappingExtension_square.R

stemMappingExtension_squareR Documentation

Extend stem mapping to a target area and shape.

Description

The function extends stem mapping in a square plot to a target area and shape.

Usage

stemMappingExtension_square(
  objectID,
  bearing,
  distance,
  plotLength,
  targetArea = 1,
  targetShape = "square",
  randomRotate = FALSE
)

Arguments

objectID

character, A object's ID, e.g., a tree's ID.

bearing

numeric, Bearing of a object from the north. It should be between 0 to 360.

distance

numeric, Distance between a object and the centre of the circle.

plotLength

numeric, Length of a square plot.

targetArea

numeric, Defines the area you may want to extend. The unit of this input is ha. Default is 1 ha.

targetShape

character, Defines the shape of the target area. It currently supports circle and square. The default is square.

randomRotate

logical, Defines whether need to random rotate the hexagon when merge into a targetArea. The default is FALSE.

Value

A table contains the x and y for all the objects in the extended area.

Author(s)

Yong Luo

Examples

## Not run: 
## randomly generate some trees
library(data.table)
smallplottrees <- data.table(tree_id = 1:20,
                             angle = runif(20, min = 0, max = 360),
                             distance = runif(20, min = 0, max = 5.6))
## extend it to 1 ha
treelist_smallplot <- stemMappingExtension_square(objectID = smallplottrees$tree_id,
                                           bearing = smallplottrees$angle,
                                           distance = smallplottrees$distance,
                                           radius = 5.64,
                                           randomRotate = TRUE)


bigplottrees <- data.table(tree_id = 1:20,
                           angle = runif(20, min = 0, max = 360),
                           distance = runif(20, min = 0, max = 11.28))
## extend it to 1 ha
treelist_bigplot <- stemMappingExtension_square(objectID = bigplottrees$tree_id,
                                         bearing = bigplottrees$angle,
                                         distance = bigplottrees$distance,
                                         radius = 11.28)
treelist_smallplot[, source := "smallplot"]
treelist_bigplot[, source := "bigplot"]


alltreelist <- rbind(treelist_bigplot, treelist_smallplot)


alltreeplot <- ggplot(data = alltreelist, aes(x, y))+
 geom_point(aes(col = factor(source)))


## End(Not run)


bcgov/FAIBBase documentation built on June 19, 2024, 11:57 p.m.