# Assuming skeleton1 is already defined as in the previous example
# Outer polygon
vertices = matrix(c(0,0, 7,0, 7,7, 0,7, 0,0), ncol = 2, byrow = TRUE)
# Holes inside the polygon
hole1 = matrix(c(1,1, 1,2, 2,2, 2,1, 1,1), ncol = 2, byrow = TRUE)
hole2 = matrix(c(5,5, 5,6, 6,6, 6,5, 5,5), ncol = 2, byrow = TRUE)
skeleton = skeletonize(vertices, holes = list(hole1, hole2))
if(run_docs_raybevel()) {
plot_skeleton(skeleton)
}
# Skeletonize and plot an {sf} object
if(run_docs_raybevel()) {
us_states = spData::us_states
texas = us_states[us_states$NAME == "Texas",]
plot_skeleton(skeletonize(texas))
}
# Highlighting certain links in the skeleton
max_links =which(skeleton$links$destination_time == max(skeleton$links$destination_time))
if(run_docs_raybevel()) {
plot_skeleton(skeleton, highlight_links = max_links, highlight_color = "green")
}
Run the code above in your browser using DataLab