% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/depthMatch.R
\name{depthMatch}
\alias{depthMatch}
\title{Match the depth values given in an occurrence dataset to the depth slice
values of a user provided spatRaster stack}
\usage{
depthMatch(occs, rasterTemplate)
}
\arguments{
\item{occs}{dataframe of occurrence records with colnames "longitude," "latitude,"
and "depth." Depth values should be positive.}

\item{rasterTemplate}{a spatRaster stack where the layer names correspond to the depth value,
as a positive number}
}
\value{
object of class dataframe, the same occs fed into the function but with the
depth values adjusted to match the spatRaster stack depth slices
}
\description{
assigns coordinates to depth slices given a user provided raster template.
if any points are deeper than the lowest depth slice, they are assigned to the
lowest depth slice.
}
\details{
rasterTemplate names and values in the depth column of occs should be positive.
Points lower than the deepest depth slice are assigned to the deepest depth slice
}
\examples{
library(terra)
# Create test raster brick
r1 <- rast(ncol = 100, nrow = 100)
r2 <- rast(ncol = 100, nrow = 100)
r3 <- rast(ncol = 100, nrow = 100)
rbrick <- c(r1, r2, r3)
names(rbrick) <- c(1, 40, 90)

# 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)

# Here's the function
result <- depthMatch(occs = occs, rasterTemplate = rbrick)

}
\keyword{cleaning}
\keyword{occurrence}
