Skip to contents

spa_boundary_pregion() yields a specific part of the fuzzy boundary of a plateau region object. This function is deprecated; use spa_boundary().

Usage

spa_boundary_pregion(pregion, bound_part = "region")

Arguments

pregion

A pregion object. It throws an error if a different type is given.

bound_part

A character value that indicates the part of the fuzzy boundary to be returned. It can be "region" or "line". See below for more details.

Value

A pgeometry object that represents a specific part of the fuzzy boundary of pgeometry object given as input.

Details

The spa_boundary_pregion() function employs the definition of fuzzy boundary of a fuzzy region object in the context of Spatial Plateau Algebra. The fuzzy boundary of a fuzzy region object A has a heterogeneous nature since it consists of two parts:

  • a fuzzy line object that corresponds to the boundary of the core of A.

  • a fuzzy region object that comprises all points of A with a membership degree greater than 0 and less than 1.

This means that spa_boundary_pregion() can yield one specific part of the fuzzy boundary of a plateau region object. If boundary = "line", then the function returns the boundary plateau line of pregion (i.e., returns a pline object). Else if boundary = "region" (the default value), then the function returns the boundary plateau region of pregion (i.e., returns a pregion object).

This function is deprecated; use spa_boundary().

Examples

# \dontrun{
library(tibble)
library(sf)
library(ggplot2)

# defining two different types of membership functions
trap_mf <- function(a, b, c, d) {
  function(x) {
    pmax(pmin((x - a)/(b - a), 1, (d - x)/(d - c), na.rm = TRUE), 0)
  }
}

trim_mf <- function(a, b, c) {
  function(x) {
    pmax(pmin((x - a)/(b - a), (c - x)/(c - b), na.rm = TRUE), 0)
  }
}

set.seed(7)
tbl = tibble(x = runif(10, min = 0, max = 30), 
             y = runif(10, min = 0, max = 50), 
             z = runif(10, min = 0, max = 100))
classes <- c("cold", "hot")
cold_mf <- trap_mf(0, 10, 20, 35)
hot_mf <- trim_mf(35, 50, 100)

# 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)))

# Using the standard fuzzification policy based on fuzzy sets
pregions <- spa_creator(tbl, classes = classes, mfs = c(cold_mf, hot_mf), base_poly = ch)
plot(pregions$pgeometry[[1]]) + ggtitle("Cold")

plot(pregions$pgeometry[[2]]) + ggtitle("Hot")


# these functions are now deprecated, use `spa_boundary()`

# capturing and showing the boundary plateau line of each pgeometry object previously created
(spa_boundary_pregion(pregions$pgeometry[[1]], bound_part = "line")) 
#> Warning: 'spa_boundary_pregion' is deprecated.
#> Use 'spa_boundary' instead.
#> See help("Deprecated")
#> [1] "PLATEAULINE EMPTY"
(spa_boundary_pregion(pregions$pgeometry[[2]], bound_part = "line"))
#> Warning: 'spa_boundary_pregion' is deprecated.
#> Use 'spa_boundary' instead.
#> See help("Deprecated")
#> [1] "PLATEAULINE EMPTY"
# this part of the boundary is empty because there is no core! 
# capturing and showing the boundary plateau region (this is the default behavior)
(spa_boundary_pregion(pregions$pgeometry[[1]]))
#> Warning: 'spa_boundary_pregion' is deprecated.
#> Use 'spa_boundary' instead.
#> See help("Deprecated")
#> [1] "PLATEAUREGION ((POLYGON ((2.823489 14.29299, 7.237678 16.13045, 19.62547 10.77187, 14.66711 2.780492, 10.23901 3.496961, 2.823489 14.29299)), 0.365178430763384), (POLYGON ((14.66711 2.780492, 19.62547 10.77187, 21.99614 12.81395, 28.05141 4.595828, 25.53715 1.021713, 14.66711 2.780492)), 0.656457394361496))"
(spa_boundary_pregion(pregions$pgeometry[[2]]))
#> Warning: 'spa_boundary_pregion' is deprecated.
#> Use 'spa_boundary' instead.
#> See help("Deprecated")
#> [1] "PLATEAUREGION ((POLYGON ((4.223299 43.96373, 8.578564 43.34816, 12.47967 36.91792, 3.159718 31.00388, 3.470933 38.6406, 4.223299 43.96373)), 0.00659261224791408), (POLYGON ((3.054677 28.42634, 14.00831 22.52261, 7.237678 16.13045, 2.823489 14.29299, 2.482768 14.39259, 3.054677 28.42634)), 0.0225217118859291), (POLYGON ((8.578564 43.34816, 4.223299 43.96373, 4.975665 49.28685, 8.578564 43.34816)), 0.057951174210757), (POLYGON ((24.18653 17.62137, 21.99614 12.81395, 19.62547 10.77187, 7.237678 16.13045, 14.00831 22.52261, 20.12681 24.31306, 24.18653 17.62137)), 0.0814723167568445), (POLYGON ((2.482768 14.39259, 2.823489 14.29299, 10.23901 3.496961, 2.09246 4.815077, 2.482768 14.39259)), 0.187957359477878), (POLYGON ((29.41458 4.511317, 28.05141 4.595828, 21.99614 12.81395, 24.18653 17.62137, 29.66728 8.587404, 29.41458 4.511317)), 0.72110211616382), (POLYGON ((20.12681 24.31306, 14.00831 22.52261, 3.054677 28.42634, 3.159718 31.00388, 12.47967 36.91792, 20.12681 24.31306)), 0.745922483038157), (POLYGON ((25.53715 1.021713, 28.05141 4.595828, 29.41458 4.511317, 29.16188 0.43523, 25.53715 1.021713)), 0.936500272403161))"
# }