Skip to contents

pcollection_to_pcomposition() converts a plateau collection object into an equivalent plateau composition object.

Usage

pcollection_to_pcomposition(pcol)

Arguments

pcol

A pcollection object.

Value

A pcomposition object.

Details

The pcollection_to_pcomposition() function yields a pcomposition object that is equivalent to the pcollection object given as input by aggregating all spatial plateau objects by type.

Examples

# Point components
pcp1 <- create_component("POINT(0 0)", 0.3)
pcp2 <- create_component("MULTIPOINT((2 2), (2 4), (2 0))", 0.5)
pcp3 <- create_component("MULTIPOINT((1 1), (3 1), (1 3), (3 3))", 0.9)
pcp4 <- create_component("MULTIPOINT((10 10), (9 8), (7 7))", 1)
pcp5 <- create_component("MULTIPOINT((0 0), (2 3))", 0.7)
pcp6 <- create_component("MULTIPOINT((0 1), (3 3))", 0.85)
pcp7 <- create_component("MULTIPOINT((1 0), (2 3))", 0.4)
# Line components
lcp1 <- create_component("LINESTRING(0 0, 1 1.5)", 0.2)
lcp2 <- create_component("LINESTRING(1 3, 1 2, 2 0.5)", 0.5)
lcp3 <- create_component("LINESTRING(2 1.2, 3 1.6, 4 4)", 0.7)
lcp4 <- create_component("LINESTRING(1 1.5, 2 1.2)", 1.0)
lcp5 <- create_component("LINESTRING(-1 1, 2 2)", 0.9)
# Polygon components
rcp1 <- create_component("POLYGON((0 0, 1 4, 2 2, 0 0))", 0.4)
rcp2 <- create_component("POLYGON((2 0.5, 4 1, 4 0, 2 0.5))", 0.8)

# Creating plateau point objects
ppoint1 <- create_pgeometry(list(pcp1, pcp2, pcp3), "PLATEAUPOINT")
ppoint2 <- create_pgeometry(list(pcp4, pcp5), "PLATEAUPOINT")
ppoint3 <- create_pgeometry(list(pcp4, pcp5), "PLATEAUPOINT")
ppoint4 <- create_pgeometry(list(pcp6, pcp7), "PLATEAUPOINT")
# Creating plateau line objects
pline1 <- create_pgeometry(list(lcp1, lcp3), "PLATEAULINE")
pline2 <- create_pgeometry(list(lcp2, lcp4), "PLATEAULINE")
pline3 <- create_pgeometry(list(lcp5), "PLATEAULINE")
# Creating a plateau region objects
pregion <- create_pgeometry(list(rcp1, rcp2), "PLATEAUREGION")
# Creating a plateau composition object
pcomposition <- create_pgeometry(list(ppoint4, pline3), "PLATEAUCOMPOSITION")
# Creating plateau collection objects
pcol1 <- create_pgeometry(list(ppoint1, ppoint2, ppoint3, pline1), "PLATEAUCOLLECTION")
pcol2 <- create_pgeometry(list(pline2, pregion, pcomposition, pcol1), "PLATEAUCOLLECTION")
pcol2
#> [1] "PLATEAUCOLLECTION (PLATEAULINE ((LINESTRING (1 3, 1 2, 2 0.5), 0.5), (LINESTRING (1 1.5, 2 1.2), 1)), PLATEAUREGION ((POLYGON ((0 0, 1 4, 2 2, 0 0)), 0.4), (POLYGON ((2 0.5, 4 1, 4 0, 2 0.5)), 0.8)), PLATEAUCOMPOSITION (PLATEAUPOINT ((MULTIPOINT ((1 0), (2 3)), 0.4), (MULTIPOINT ((0 1), (3 3)), 0.85)), PLATEAULINE ((LINESTRING (-1 1, 2 2), 0.9)), PLATEAUREGION EMPTY), PLATEAUCOLLECTION (PLATEAUPOINT ((POINT (0 0), 0.3), (MULTIPOINT ((2 2), (2 4), (2 0)), 0.5), (MULTIPOINT ((1 1), (3 1), (1 3), (3 3)), 0.9)), PLATEAUPOINT ((MULTIPOINT ((0 0), (2 3)), 0.7), (MULTIPOINT ((10 10), (9 8), (7 7)), 1)), PLATEAUPOINT ((MULTIPOINT ((0 0), (2 3)), 0.7), (MULTIPOINT ((10 10), (9 8), (7 7)), 1)), PLATEAULINE ((LINESTRING (0 0, 1 1.5), 0.2), (LINESTRING (2 1.2, 3 1.6, 4 4), 0.7))))"
plot(pcol2)

# \dontrun{
converted_pcomp <- pcollection_to_pcomposition(pcol2)
converted_pcomp
#> [1] "PLATEAUCOMPOSITION (PLATEAUPOINT ((POINT (1 0), 0.4), (MULTIPOINT ((2 0), (2 4)), 0.5), (POINT (2 3), 0.7), (POINT (0 1), 0.85), (MULTIPOINT ((3 1), (3 3)), 0.9), (MULTIPOINT ((7 7), (9 8), (10 10)), 1)), PLATEAULINE ((LINESTRING (1.4 1.4, 2 0.5), 0.5), (LINESTRING (2 1.2, 3 1.6, 4 4), 0.7), (LINESTRING (-1 1, 0.3636364 1.454545), 0.9), (LINESTRING (1.384615 1.384615, 2 1.2), 1)), PLATEAUREGION ((POLYGON ((0 0, 0.3636364 1.454545, 1 4, 2 2, 1.4 1.4, 1.384615 1.384615, 0 0)), 0.4), (POLYGON ((2 0.5, 4 1, 4 0, 2 0.5)), 0.8)))"
plot(converted_pcomp)

# }