Skip to contents

create_component() builds an object of class component. A component consists of a crisp spatial object (sfg object) labeled with a membership degree in ]0, 1]. It is a flexible function since the crisp spatial object can be provided by using different formats.

Usage

create_component(obj, md, ...)

component_from_sfg(sfg, md)

Arguments

obj

A crisp spatial object in a specific format (see details below).

md

A numeric value indicating the membership degree of the component. It must be a value in ]0, 1].

...

<dynamic-dots> Different parameters that are used to convert a crisp spatial object from a specific representation (see more in details below).

sfg

An sfg object. It should be either of type POINT, MULTIPOINT, LINESTRING, MULTILINESTRING, POLYGON or MULTIPOLYGON. Other types of spatial objects are not allowed.

Value

A component object that can be added to a spatial plateau object (i.e., a pgeometry object).

Details

The create_component() function creates a component object. Internally, it is a pair of an sfg object and a membership degree in ]0, 1].

obj can be either (see restrictions regarding its data type below):

  • an sfg object.

  • a character vector containing the WKT representation of a crisp spatial object.

  • a structure of class "WKB" with the WKB or EWKB representation of a crisp spatial object. If the EWKB representation is used, then you have to provide the additional parameter EWKB = TRUE in ....

  • a vector, list, or matrix containing coordinate pairs to be used when creating the sfg object. This means that it has a similar behavior to the family of functions st of the sf package (e.g., st_point(), st_multipoint(), etc.). Thus, you have to provide the additional parameter type in ..., which should be either "POINT", "LINE", or "REGION".

It is important to emphasize that the crisp spatial object must be a simple or complex point, line, or region (i.e., polygon) object. That is, it should be a POINT, MULTIPOINT, LINESTRING, MULTILINESTRING, POLYGON or MULTIPOLYGON object. If other types of crisp spatial objects are given, an error will be thrown.

The component_from_sfg() function is deprecated.

Examples

# first way: providing sfg objects
library(sf)

pts <- rbind(c(1, 2), c(3, 2))
comp1 <- create_component(st_multipoint(pts), 0.2) 

lpts <- rbind(c(2, 2), c(3, 3))
comp2 <- create_component(st_linestring(lpts), 0.1) 

matrix_obj <- matrix(c(1,1,8,1,8,8,1,8,1,1), ncol = 2, byrow = TRUE)
rpts <- list(matrix_obj)
comp3 <- create_component(st_polygon(rpts), 0.4)

# second way: providing WKT representations
comp4 <- create_component("POINT(10 35)", 0.5)
comp5 <- create_component("MULTILINESTRING((-29 -27, -36 -31, -45 -33), (-45 -33, -46 -32))", 0.9)
comp6 <- create_component("POLYGON((75 29, 77 29, 77 29, 75 29))", 1)

# third way: providing WKB representations
wkb = structure(list("0x0101000020e610000000000000000000000000000000000040"), class = "WKB")
comp7 <- create_component(wkb, 0.8, EWKB = TRUE)

# fourth way: providing coordinate pairs
coords1 = rbind(c(2,2), c(3,3))
coords2 = rbind(c(1,1), c(3,2))

comp8 <- create_component(coords1, 0.45, type = "LINE")
comp9 <- create_component(coords2, 0.32, type = "POINT")