R/IoU.R

Defines functions IoU

#based on: https://rdrr.io/github/weecology/NeonTreeEvaluation_package/man/IoU.html

IoU <- function(x, y) {
  #calculate the area of intersection
  intersection <- st_intersection(st_geometry(x), st_geometry(y))
  if (length(intersection)==0) {
    return(0)
  }
  area_intersection <-  st_area(intersection)
  #calculate the area of union
  area_union <- (st_area(x) + st_area(y)) - area_intersection
  return(area_intersection/area_union)
}
keltoskytoi/iSEGMound documentation built on Dec. 21, 2021, 5:24 a.m.