patches | R Documentation |
The function calculates the face names that represent patches in a surface shape
## S4 method for signature 'trigrid'
patches(x, y, ...)
## S4 method for signature 'facelayer'
patches(x)
x |
( |
y |
( |
... |
Arguments passed to class-specific methods. |
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.
A named numeric vector, names correspond to faces, numbers define the patches.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.