library(sf)
pts <- rbind(c(0, 2), c(4, 2))
# Point components
pcp1 <- create_component(st_multipoint(pts), 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)
# 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)
# 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 spatial plateau objects
pp <- create_pgeometry(list(pcp1, pcp2, pcp3), "PLATEAUPOINT")
pl <- create_pgeometry(list(lcp1, lcp3, lcp4), "PLATEAULINE")
pr <- create_pgeometry(list(rcp1, rcp2), "PLATEAUREGION")
pcm <- create_pgeometry(list(pcp1, pcp2, lcp1, lcp2, lcp3, rcp2), "PLATEAUCOMPOSITION")
pcl <- create_pgeometry(list(pp, pr, pcm), "PLATEAUCOLLECTION")
# Displaying their textual representations
pp
pl
pr
pcm
pcl
# Plotting them
plot(pp)
plot(pl)
plot(pr)
plot(pcm)
plot(pcl)
if (FALSE) {
# Custom colors
fsr_plot(pr, low = "green", high = "blue")
# Changing the line width of line components
fsr_plot(pl, line_lwd = 2)
# Changing the line width of boundary lines of region components
fsr_plot(pr, region_lwd = 2)
# Changing the line width of boundary lines of region components and its color
fsr_plot(pr, region_lwd = 2, color = "blue")
# You can customize the whole visualization using ggplot
library(ggplot2)
fsr_plot(pp, size = 5) +
theme(legend.position = "none") +
theme(text=element_text(size=20, family = "serif", color = "black"),
axis.text=element_text(color="black")) +
scale_x_continuous(breaks = c(0, 1, 2, 3, 4)) +
scale_y_continuous(breaks = c(0, 1, 2, 3, 4))
}
Run the code above in your browser using DataLab