BAplot: Plot basal areas on a map of quadrats

View source: R/BAplot.R

BAplotR Documentation

Plot basal areas on a map of quadrats

Description

Plot basal areas of trees on a map of quadrats. If individual tree coordinates are not known, the coordinates inside the quadrats are randomly defined according to the uniform distribution.

Usage

BAplot(
  formula,
  data,
  taxon = "taxon",
  circumference = TRUE,
  quadrat.size,
  dead = "dead",
  rm.dead = FALSE,
  origin = c(0, 0),
  col = "grey40",
  alpha = 1,
  cex.radius = 1,
  ind.coord = FALSE,
  legend = TRUE,
  long = FALSE
)

Arguments

formula

A model formula indicating the trunk measure (circumference [default] or diameter) in centimeters and the xy coordinates of each quadrat the tree belongs (ind.coord = FALSE) or, the actual tree coordinates (ind.coord = TRUE). Example: measure ~ x + y. See Details.

data

A data frame containing the community sample data. See Details.

taxon

Name of the column representing the sampled taxa. Default is "taxon".

circumference

Logical. If TRUE (the default), the function assumes that the circumference at breast height was measured.

quadrat.size

A vector indicating the side lengths (in meters) of the x and y quadrat sides (e.g., c(x, y)). It can be given as a single value if the quadrat is a square.

dead

String used to identify the dead individuals. Default is "dead".

rm.dead

Logical. If FALSE (the default) basal areas of dead individuals are plotted.

origin

A numeric vector indicating the map origin coordinates. Default is c(0, 0).

col

Circle color of represented basal areas. This argument has value only if legend = FALSE. Default is "grey40".

alpha

Value of transparency factor: zero (100% transparent) – 1 (no transparency). Default is 1.

cex.radius

A numerical value giving the amount by which the tree radius should be magnified relative to the actual measure. Default is 1.

ind.coord

Logical indicating whether the individual coordinates are given. If FALSE (the default) the tree coordinates inside the quadrats are randomly defined. If TRUE, the actual tree coordinates are plotted.

legend

Logical. If TRUE (default), the taxon is used as the color legend; otherwise, circle color will be defined by the argument col.

long

Logical. If FALSE (default) the function does not return the result data frame, which contains xy coordinates, radius and taxon name of each sampled tree.

Details

BAplot uses the function circleRepelLayout() from the packcircles package to rearrange circle coordinates to avoid overlapping. The minimum distance allowed among trees is 1 meter. The packages ggforce and ggplot2 are used to draw the map.

The data frame passed to the data argument must include two columns indicating x and y coordinates of each quadrat that the tree belongs or the actual tree coordinates. If actual coordinates are supplied, the ind.coord argument must be set TRUE.

Circumference/diameter measures accept the traditional notation for multiple trunks, e.g., "17.1+8+5.7+6.8". The plus sign is the separator for each trunk measure. Decimal separator can be point or comma and spaces after or before "+" are ignored by the function.

Value

A plot representing the quadrat map and tree basal areas. If long = TRUE, the function returns a data frame containing taxon name, xy coordinates and radius of each sampled tree.

Author(s)

Rodrigo A. S. Pereira (raspereira@usp.br)

References

Collins, C. R., and Stephenson, K. (2003). A circle packing algorithm. Computational Geometry, 25(3), 233–256. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/S0925-7721(02)00099-8")}

Wang, W., Wang, H., Dai, G., and Wang, H. (2006). Visualization of large hierarchical data by circle packing. Proceedings of the SIGCHI Conference on Human Factors in Computing Systems, 517–520. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1145/1124772.1124851")}

Examples

# Using plot coordinates (random coordinates for individuals)
data1 <- quadrat2_plot.df
BAplot(formula = CBH ~ x + y, data = data1, taxon = "Species",
       circumference = TRUE, quadrat.size = 5, dead = "Morta",
       rm.dead = FALSE, alpha = 0.4, cex.radius = 2,
       legend = TRUE, long = FALSE, ind.coord = FALSE)

# Using actual coordinates
data2 <- quadrat2_tree.df
BAplot(formula = CBH ~ x + y, data = data2, taxon = "Species",
       circumference = TRUE, quadrat.size = 5, dead = "Morta",
       rm.dead = FALSE, alpha = 0.4, cex.radius = 2,
       legend = TRUE, long = FALSE, ind.coord = TRUE)

# Rectangular plots and plot coordinates
data3 <- quadrat3_rect.df
BAplot(formula = DBH ~ x + y, data = data3, taxon = "Species",
       circumference = FALSE, quadrat.size = c(20, 10),
       dead = "Morta", rm.dead = FALSE, col = "blue",
       alpha = 0.4, cex.radius = 2, legend = FALSE,
       long = FALSE, ind.coord = FALSE)


PhytoIn documentation built on Nov. 5, 2025, 5:47 p.m.