Skip to contents

This function divides a plot (or several plots) into subplots in the relative coordinates system, and returns the coordinates of subplot corners.

Usage

divide_plot(
  rel_coord,
  proj_coord = NULL,
  grid_size,
  plot_ID_corner = NULL,
  tree_coord = NULL,
  plot_ID_tree = NULL
)

Arguments

rel_coord

a data frame containing the relative (local) coordinates of plot corners, with X and Y corresponding to the first and second column respectively

proj_coord

a data frame containing the projected coordinates of plot corners, with X and Y corresponding to the first and second column respectively, and with the same row order than rel_coord

grid_size

a vector indicating the dimensions of grid cells (resp. X and Y dimensions). If only one value is given, grid cells will be considered as squares.

plot_ID_corner

if dealing with multiple plots : a vector indicating plot IDs for corners.

tree_coord

a data frame containing at least the relative tree coordinates (field/local coordinates), with X and Y corresponding to the first and second columns respectively

plot_ID_tree

if dealing with multiple plots : a vector indicating tree plot IDs.

Value

If tree_coord isn't supplied, returns a data-frame containing as many rows as there are corners corresponding to the subplots, and the following columns :

  • plot_ID_corner: If dealing with multiple plots : the plot code

  • subplot_id: The automatically generated subplot code, using the following rule : subplot_X_Y

  • x and y (or the column names provided by rel_coord) : the relative X-axis and Y-axis coordinates of subplots corners.

  • x_proj and y_proj (or the column names provided by proj_coord) : if proj_coord is supplied, the projected X-axis and Y-axis coordinates of subplots corners

If tree_coord is supplied, returns a list containing the previous data-frame and a data-frame containing for each tree :

  • the relative coordinates

  • the subplot_id associated

  • the rest of tree_coord columns supplied

Details

If corner coordinates in the projected coordinate system are supplied (proj_coord), projected coordinates of subplot corners are calculated by a bilinear interpolation in relation with relative coordinates of plot corners. Be aware that this bilinear interpolation only works if the plot in the relative coordinates system is rectangular (ie, has 4 right angles).

Author

Arthur PERE, Arthur BAILLY

Examples


# Rectangular plot and grid cells
rel_coord <- data.frame(x_rel = c(0, 200, 0, 200), y_rel = c(0, 0, 100, 100))
subplots <- divide_plot(rel_coord, grid_size = c(100,50))

# Squared plot
rel_coord <- data.frame(x_rel = c(0, 200, 0, 200), y_rel = c(0, 0, 200, 200))
proj_coord <- data.frame(x_proj = c(110, 190, 60, 145), y_proj = c(110, 160, 196, 245))
subplots <- divide_plot(rel_coord, proj_coord = proj_coord, grid_size = 100)

tree_coord <- data.frame(x_proj = runif(50,0,200), y_proj = runif(50,0,200))
subplots <- divide_plot(rel_coord, proj_coord = proj_coord, grid_size = 100, tree_coord = tree_coord)

# Dealing with multiple plots 
rel_coord <- rbind(rel_coord, rel_coord)
proj_coord <- rbind(proj_coord, proj_coord + 200)
tree_coord <- rbind(tree_coord, data.frame(x_proj = runif(50,0,200), y_proj = runif(50,0,200)))
plot_ID_corner <- rep(c("plot1","plot2"), e=4)
plot_ID_tree <- rep(c("plot1","plot2"), e=50)
subplots <- divide_plot(rel_coord, proj_coord, 100, plot_ID_corner, tree_coord, plot_ID_tree)