Learn R Programming

icosa (version 0.12.0)

patches: Patches of shapes on an icosahedral grid

Description

The function calculates the face names that represent patches in a surface shape

Usage

# S4 method for trigrid
patches(x, y, ...)

# S4 method for facelayer patches(x)

Value

A named numeric vector, names correspond to faces, numbers define the patches.

Arguments

x

(trigrid, hexagrid or facelayer) An icosahedral grid or associated facelayer object.

y

(character) Horizontal shapes defined as a character vector of face names.

...

Arguments passed to class-specific methods.

Details

The function uses the horizontal graph of a trigrid-class object, and searches for isolated subgraphs. This function relies on the igraph package to run.

Examples

Run this code

# create a grid
hex <- hexagrid(2, sf=TRUE)
# an example shape
shape <- paste0("F", c(3,6,7,9, 10, 16, 22, 26))

# visualize basic grid
plot(hex)
gridlabs(hex)

# visualize the shape
plot(hex, shape, col="#FF000055", add=TRUE)

# calculate holes
pa <- patches(x=hex, y=shape)

# plot all patches (coloring borders)
plot(hex, names(pa[pa==1]), add=TRUE, border="#00FF00", lwd=4)
plot(hex, names(pa[pa==2]), add=TRUE, border="#0000FF", lwd=4)
plot(hex, names(pa[pa==3]), add=TRUE, border="#00FFFF", lwd=4)

Run the code above in your browser using DataLab