CombinePolygons {bfsMaps}R Documentation

Combine Multiple Polygons to One Spatial Polygon

Description

The function combines polygons to one single spatial polygon object, according to the ID vector that specifies which input polygons belong to which output polygon.

Usage

CombinePolygons(map, g)

CombineKant(id, g, map = GetMap("kant.map"))
CombinePolg(id, g, map = GetMap("polg.map"))

Arguments

map

the map containing the regions to be combined.

id

the id of the cantons or communities to be aggregated.

g

a vector defining the assignment of the elements to the output polygons to be created. It may contain NA values for input objects not included in the union.

Value

Returns an aggregated spatial polygons object named with the aggregated IDs values in their sorting order; see the ID values of the output object to view the order.

Author(s)

Juerg Guggenbuehl, Andri Signorell <andri@signorell.net>

See Also

st_union

Examples

require(DescTools)

try( {

# Representation of the language areas in CH combined via cantons
# by majority per canton
tkt <- table(d.bfsrg$kt_c, d.bfsrg$sprgeb_x)
grp <- unique(d.bfsrg$sprgeb_x)[apply(tkt, 1, which.max)]

# combine and plot cantons
plot(CombineKant(rownames(tkt), grp), col=SetAlpha(c(horange, hyellow, hecru), 0.8),
     border="grey40", main="Languages in CH")

# copyright is mandatory for these SFSO maps
BfSStamp()
# waters make the maps more realistic ...
AddLakes(col = "grey80", border = "grey40")

})

[Package bfsMaps version 1.99.3 Index]