# NOT RUN {
# Creating two components of the type POINT
v1 = rbind(c(1,2), c(3,4))
v2 = rbind(c(1,4), c(2,3),c(4,4))
md1 = 0.2
md2 = 0.1
comp1 <- create_component(v1, md1, type="POINT")
comp2 <- create_component(v2, md2, type="POINT")
# Creating two components of the type LINE
md3 = 0.45
md4 = 0.32
v3 = rbind(c(2,2), c(3,3))
v4 = rbind(c(1,1), c(3,2))
comp3 <- create_component(v3, md3, type="LINE")
comp4 <- create_component(v4, md4, type="LINE")
# Creating two components of the type REGION
p1 <- rbind(c(0,0), c(1,0), c(3,2), c(2,4), c(1,4), c(0,0))
p2 <- rbind(c(1,1), c(1,2), c(2,2), c(1,1))
list_pols_1 <- list(p1,p2)
p3 <- rbind(c(1,0), c(2,0), c(4,2), c(3,4), c(2,4), c(1,0))
p4 <- rbind(c(2,2), c(2,3), c(3,4), c(2,2))
list_pols_2 <- list(p3,p4)
comp_pol1 <- create_component(list_pols_1, 0.4, "REGION")
comp_pol2 <- create_component(list_pols_2, 0.6, "REGION")
# Creating components with an sfg object
library(sf)
# POINT
md1 <- 0.2
pts1 <- rbind(c(1, 2), c(3, 2))
comp1 <- component_from_sfg(st_multipoint(pts1), md1)
# LINE
md2 <- 0.1
pts2 <- rbind(c(2, 2), c(3, 3))
comp2 <- component_from_sfg(st_linestring(pts2), md2)
# REGION
md3 <- 0.4
matrix_object = matrix(c(1,1,8,1,8,8,1,8,1,1),ncol=2, byrow=TRUE)
pts3 = list(matrix_object)
comp3 = component_from_sfg(st_polygon(pts3), md3)
# }
Run the code above in your browser using DataLab