if (FALSE) {
library(tibble)
library(sf)
set.seed(456)
# Generating some random points to create pgeometry objects by using spa_creator()
tbl = tibble(x = runif(10, min= 0, max = 30),
y = runif(10, min = 0, max = 30),
z = runif(10, min = 0, max = 50))
# Getting the convex hull on the points to clip plateau region objects during their constructions
pts <- st_as_sf(tbl, coords = c(1, 2))
ch <- st_convex_hull(do.call(c, st_geometry(pts)))
pregions <- spa_creator(tbl, base_poly = ch, fuzz_policy = "fcp", k = 2)
plot(pregions$pgeometry[[1]])
plot(pregions$pgeometry[[2]])
# Showing results for spa_overlap() by considering default list of classes
spa_overlap(pregions$pgeometry[[1]], pregions$pgeometry[[2]], ret = "list")
}
# Changing the default classification
trap_mf <- function(a, b, c, d) {
function(x) {
pmax(pmin((x - a)/(b - a), 1, (d - x)/(d - c), na.rm = TRUE), 0)
}
}
classes <- c("superficially", "moderately", "completely")
superficially <- trap_mf(0, 0.2, 0.4, 0.6)
moderately <- trap_mf(0.4, 0.6, 0.8, 1)
completely <- trap_mf(0.6, 0.8, 1, 1)
spa_set_classification(classes, c(superficially, moderately, completely))
if (FALSE) {
# Now the fuzzy topological relationships will use the new classification
spa_overlap(pregions$pgeometry[[1]], pregions$pgeometry[[2]], ret = "list")
}
Run the code above in your browser using DataLab