Skip to contents

spa_set_classification() configures a new set of linguistic values and corresponding membership functions to be used by fuzzy topological relationships.

Usage

spa_set_classification(classes, mfs)

Arguments

classes

A character vector containing linguistic values that characterizes different situations of fuzzy topological relationships.

mfs

A vector of membership functions with domain in [0, 1].

Value

No return values, called for side effects.

Details

The spa_set_classification() function replaces the default linguistic values employed by fuzzy topological relationships. Each membership function i of the parameter mfs represents the class i of the parameter classes. The length of these parameters must to be equal.

Examples

# \dontrun{
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")
#> $superficially
#> [1] 0.1976317
#> 
#> $moderately
#> [1] 0
#> 
#> $completely
#> [1] 0
#> 
# }
# 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))
# \dontrun{
# Now the fuzzy topological relationships will use the new classification
spa_overlap(pregions$pgeometry[[1]], pregions$pgeometry[[2]], ret = "list")
#> $superficially
#> [1] 0.1976317
#> 
#> $moderately
#> [1] 0
#> 
#> $completely
#> [1] 0
#> 
# }