Skip to content

Commit

Permalink
Merge pull request #377 from sjevelazco/extr
Browse files Browse the repository at this point in the history
calib_area was speeded up
  • Loading branch information
sjevelazco authored May 13, 2024
2 parents 1691570 + a6d260a commit f550efe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ importFrom(terra,freq)
importFrom(terra,geom)
importFrom(terra,global)
importFrom(terra,is.factor)
importFrom(terra,is.related)
importFrom(terra,lapp)
importFrom(terra,levels)
importFrom(terra,mask)
Expand Down
7 changes: 4 additions & 3 deletions R/calib_area.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#'
#' @importFrom grDevices chull
#' @importFrom methods as is
#' @importFrom terra vect buffer aggregate union crs extract
#' @importFrom terra vect buffer aggregate union crs extract is.related
#'
#' @examples
#' \dontrun{
Expand Down Expand Up @@ -210,8 +210,9 @@ calib_area <- function(data, x, y, method, groups = NULL, crs = NULL) {
data <- data[, c("x", "y")]
data_sp <- data
data_sp <- terra::vect(data_sp, geom = names(data_sp), crs = terra::crs(polyc))
result <- terra::extract(polyc, data_sp)[, cname] %>% unique()
result <- polyc[polyc[[cname]][, 1] %in% result, ]

result <- polyc[terra::is.related(polyc, data_sp, "intersects"), cname]
# result <- polyc[polyc[[cname]][, 1] %in% result, ]
}
return(result)
}

0 comments on commit f550efe

Please sign in to comment.