spa_creator {fsr}R Documentation

Build pgeometry objects from a point dataset

Description

spa_creator() builds a set of spatial plateau objects from a given point dataset assigned with domain-specific numerical values.

Usage

spa_creator(tbl, fuzz_policy = "fsp", const_policy = "voronoi", ...)

Arguments

tbl

A data.frame or tibble object with three columns: (x, y, z).

fuzz_policy

The fuzzification policy to be employed by the algorithm. See details below.

const_policy

The construction policy to be used by the algorithm. See details below.

...

<dynamic-dots> Parameters for the chosen policies. See details below.

Details

The spa_creator() function implements a two-stage construction method that takes as input a point dataset and produces a set of spatial plateau objects as output.

The input tbl is a point dataset (data.frame or tibble object) where each point represents the location of a phenomenon treated by the application. Further, each point is annotated with numerical data that describe its meaning in the application. Therefore, tbl must have three columns: (x, y, z). The columns x, y are the coordinate pairs, and z is the column containing domain-specific numeric values.

The parameter fuzz_policy refers to the method used by the fuzzification stage. This stage aims to assign membership degrees to each point of the dataset. It accepts two possible values: "fsp" (default) or "fcp".

"fsp" stands for fuzzy set policy and requires two parameters that should be informed in ...:

"fcp" stands for fuzzy clustering policy and requires the e1071 package. Its possible parameters informed in ... are:

An optional and common parameter for both fuzzification stages is "digits". This is an integer value that indicates the number of decimal digits of the membership degrees calculated by the fuzzification stage. That is, it is used to round membership degrees to the specified number of decimal places. Be careful with this optional parameter! If you specify a low value for "digits", some membership degrees could be rounded to 0 and thus, some components would not be created.

The parameter const_policy refers to the method used by the construction stage. This stage aims to create polygons from the labeled point dataset and use them to build spatial plateau objects. It accepts three possible values: "voronoi" (default), "⁠delaunay"⁠, or "convex_hull".

"voronoi" stands for Voronoi diagram policy and has two optional parameter that can be provided in ...:

"delaunay" stands for Delaunay triangulation policy, which accepts the following parameters in ...:

"convex_hull" stands for Convex hull policy, which accepts the following parameters in ...:

Value

A tibble in the format ⁠(class, pgeometry)⁠, where class is a character column and pgeometry is a list of pgeometry objects. This means that a spatial plateau object is created for representing a specific class of the point dataset.

References

Carniel, A. C.; VenĂ¢ncio, P. V. A. B; Schneider, M. fsr: An R package for fuzzy spatial data handling. Transactions in GIS, vol. 27, no. 3, pp. 900-927, 2023.

Underlying concepts and formal definitions of the two-stage construction method is introduced in:

Examples

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)

# Using the standard fuzzification policy based on fuzzy sets
res <- spa_creator(tbl, classes = classes, mfs = c(cold_mf, hot_mf))
## Not run: 
res  
plot(res$pgeometry[[1]]) + ggtitle("Cold")
plot(res$pgeometry[[2]]) + ggtitle("Hot")

# 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)))
res <- spa_creator(tbl, classes = classes, mfs = c(cold_mf, hot_mf), base_poly = ch)
plot(res$pgeometry[[1]]) + ggtitle("Cold (with clipped boundaries)")
plot(res$pgeometry[[2]]) + ggtitle("Hot (with clipped boundaries)")
 
# Using the fuzzification policy based on fuzzy clustering
spa_creator(tbl, fuzz_policy = "fcp", k = 4)

spa_creator(tbl, fuzz_policy = "fcp", k = 4, digits = 2)

# Varying the construction policy
spa_creator(tbl, fuzz_policy = "fcp", k = 3, const_policy = "delaunay")

spa_creator(tbl, fuzz_policy = "fcp", const_policy = "delaunay", k = 3, tnorm = "prod")

spa_creator(tbl, fuzz_policy = "fcp", k = 2, digits = 2, 
            degrees = seq(0.1, 1, by = 0.1), d = 0.05, const_policy = "convex_hull")

spa_creator(tbl, classes = classes, mfs = c(cold_mf, hot_mf), const_policy = "delaunay")
            
spa_creator(tbl, classes = classes, mfs = c(cold_mf, hot_mf), 
            digits = 2, const_policy = "convex_hull")

## End(Not run)

[Package fsr version 2.0.1 Index]