R/st_overlaps_with_threshold.R

Defines functions st_overlaps_with_threshold

Documented in st_overlaps_with_threshold

#' Function Overlap based on a treshold
#' 
#' @param x spatial object
#' @param y spatial object to overlap with
#' @param treshold A treshold for the overlap
#' @export
#' 
st_overlaps_with_threshold <- function(x, y, threshold) {
  int = st_intersects(x, y)
  lapply(seq_along(int), function(ix)
    if (length(int[[ix]]))
      int[[ix]][which(st_area(st_intersection(x[ix,], y[int[[ix]],])) > threshold)]
    else
      integer(0)
  )
}  
jpablo91/STNet documentation built on Feb. 18, 2024, 7:36 a.m.