crop_area {quadcleanR} | R Documentation |
Crop quadrats based on area
Description
Using the location of annotated points within quadrats and the size of the quadrat, crop quadrat data to a smaller area, while maintaining the spatial relationships between points. Useful for making different sized quadrat data comparable.
Usage
crop_area(
data,
row,
column,
id,
dim,
obs_rm = FALSE,
obs_range,
res = FALSE,
res_dim_x,
res_dim_y
)
Arguments
data |
A data frame containing annotations, in long format, such that all observations are contained in one column. |
row |
The column name in |
column |
The column name in |
id |
The column name in |
dim |
A vector with length of 2, containing the proportion of the row and columns to crop. First element will be the proportion of the rows and the second will be the proportion of the columns. |
obs_rm |
If |
obs_range |
A vector with length of 2, specifying the min and max accepted number of annotated observations to retain in the data set. |
res |
If |
res_dim_x |
The column name in |
res_dim_y |
The column name in |
Value
A data frame in of quadrat annotations with a subset of annotated points.
Examples
#Creating the data file
tags <- c("Clad", "Sinu", "Sarco", "Loph")
site <- c(rep("Site1", times = 100),
rep("Site2", times = 100),
rep("Site3", times = 100),
rep("Site4", times = 100))
row <- c(sample(x = c(1:2000), size = 100, replace = TRUE),
sample(x = c(1:2000), size = 100, replace = TRUE),
sample(x = c(1:2000), size = 100, replace = TRUE),
sample(x = c(1:2000), size = 100, replace = TRUE))
column <- c(sample(x = c(1:2000), size = 100, replace = TRUE),
sample(x = c(1:2000), size = 100, replace = TRUE),
sample(x = c(1:2000), size = 100, replace = TRUE),
sample(x = c(1:2000), size = 100, replace = TRUE))
label <- c(sample(x = tags, size = 100, replace = TRUE),
sample(x = tags, size = 100, replace = TRUE),
sample(x = tags, size = 100, replace = TRUE),
sample(x = tags, size = 100, replace = TRUE))
coral_annotations <- data.frame(site, row, column, label)
crop_area_coral <- crop_area(data = coral_annotations, row = "row",
column = "column", id = "site", dim = c(0.5, 0.5))
coral_annotations$col_dim <- 2000
coral_annotations$row_dim <- 2000
crop_area_coral_2 <- crop_area(data = coral_annotations, row = "row",
column = "column", id = "site", dim = c(0.5, 0.5),
res = TRUE, res_dim_x = "col_dim", res_dim_y = "row_dim")