Learn R Programming

calba (version 0.1.2)

count_total: Count Total Trees

Description

This function counts the total number of trees within a given radius for each focal tree.

Usage

count_total(gx, gy, r, edge_correction = c("none", "safe"), bounds = NULL)

Value

A numeric vector containing the count of all trees within the radius for each focal tree.

Arguments

gx

A numeric vector of x-coordinates for the trees.

gy

A numeric vector of y-coordinates for the trees.

r

A numeric scalar for the radius parameter.

edge_correction

Character; see `ba_simple()` for the `"safe"` option that skips focal trees close to the edges.

bounds

Optional numeric vector `c(xmin, xmax, ymin, ymax)` giving the plot extent. When `NULL`, the range of `gx`/`gy` is used; supply bounds if your data do not span the full plot.

Examples

Run this code
sample_data <- data.frame(
  gx = runif(100, 0, 10),
  gy = runif(100, 0, 10)
)
count_total(
  gx = sample_data$gx,
  gy = sample_data$gy,
  r = 3
)

Run the code above in your browser using DataLab