| cleanDepth | R Documentation |
function to remove or flag coordinates on land, coordinates which are deeper than the known bathymetry at a given xy location, and/or coordinates outside of a specified depth range when cleaning coordinates for species in marine environments
cleanDepth(
occs,
bathy,
land_poly,
depth_range,
flag = FALSE,
bottom_correct = FALSE
)
occs |
dataframe containing columns named "longitude", "latitude", and "depth," where depth values are positive |
bathy |
a spatRaster of bathymetry in the same units as the occurrence depth, where values are negative |
land_poly |
optional polygon of continents in same projection as occurrence data |
depth_range |
optional range of depth values in the form of c(upper, lower) in which all points should fall between. depth value should be positive, as in the case of the occs |
flag |
default is F, if T, points are not removed, but flagged if they intersect, and a column is added to the output indicating what points have been flagged |
bottom_correct |
default is F, but if T, points are not removed, and a column is added to the output displaying the bathymetry value at the flagged point for corrective purposes |
assumes depths are listed as positive in the occs and depth_range, while the bathymetry layer lists them as negative when below the sea surface
an object of class dataframe containing cleaned or flagged occurrences
library(terra)
library(dplyr)
# Create sample bathymetry
r1 <- rast(ncol=10, nrow=10)
values(r1) <- c(-100:0)
# Create test occurrences
set.seed(0)
longitude <- sample(ext(r1)[1]:ext(r1)[2], size = 10, replace = FALSE)
set.seed(0)
latitude <- sample(ext(r1)[3]:ext(r1)[4], size = 10, replace = FALSE)
set.seed(0)
depth <- sample(1:100, size = 10, replace = TRUE)
occs <- data.frame(longitude, latitude, depth)
#Heres the function
result <- cleanDepth(bathy = r1, occs = occs)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.