Create a pencil layer. This function transforms a POLYGON or MULTIPOLYGON sf object into a MULTILINESTRING one.
getPencilLayer(x, size = 100, buffer = 1000, lefthanded = TRUE)
an sf object, a simple feature collection (POLYGON or MULTIPOLYGON).
density of the penciling. Median number of points used to build the MULTILINESTRING.
buffer around each polygon. This buffer (in map units) is used to take sample points. A negative value adds a margin between the penciling and the original polygons borders
if TRUE the penciling is done left-handed style.
A MULTILINESTRING sf object is returned.
library(sf)
mtq <- st_read(system.file("gpkg/mtq.gpkg", package="cartography"))
#> Reading layer `mtq' from data source
#> `/tmp/RtmpmpfIrO/temp_libpath18ee15f22a9e/cartography/gpkg/mtq.gpkg'
#> using driver `GPKG'
#> Simple feature collection with 34 features and 7 fields
#> Geometry type: MULTIPOLYGON
#> Dimension: XY
#> Bounding box: xmin: 690574 ymin: 1592536 xmax: 735940.2 ymax: 1645660
#> Projected CRS: WGS 84 / UTM zone 20N
mtq_pencil <- getPencilLayer(x = mtq)
plot(st_geometry(mtq_pencil), col = 1:8)
plot(st_geometry(mtq), add = TRUE)
typoLayer(x = mtq_pencil, var="STATUS",
col = c("aquamarine4", "yellow3","wheat"),
legend.values.order = c("Prefecture",
"Sub-prefecture",
"Simple municipality"),
legend.pos = "topright",
legend.title.txt = "Status")
plot(st_geometry(mtq), add = TRUE, ldy=2)
layoutLayer(title = "Municipality Status")