{"word_count": 249, "character_count": 2032}
This post shows how to build a colored pencil map with R.The cartography package (in its development version) has gained a getPencilLayer() function that transforms a POLYGON or MULTIPOLYGON layer into a MULTILINESTRING layer mimicking a pencil drawing pattern.The following code details how to use the function:#download the dev version of cartographydevtools::install_github("riatelab/cartography")library(cartography)library(sf)# import a vector layer (here a shapefile)mtq &#60;- st_read(system.file("shape/martinique.shp", package="cartography"))# display this POLYGON layerplot(st_geometry(mtq), col = 1:8)&#160;# transform the POLYGON layer in a MULTILINESTRING layermtq_pencil &#60;- getPencilLayer(x = mtq)# display this MULTILINESTRING layerplot(st_geometry(mtq_pencil), col = 1:8)# and a add the original bordersplot(st_geometry(mtq), col = NA, add=T)getPencilLayer() produces a MULTILINESTRING sf data frame that keeps original data, hence the possibility to use this layer in mapping functions (such as choroLayer() or typoLayer()):# Share of farmers in the active populationmtq$shareCS1 &#60;- 100 * mtq$C13_CS1/mtq$C13_POP# transform communes polygons to multilinestringsmtq_pencil &#60;- getPencilLayer(mtq, size = 500, lefthanded = FALSE)# plot the Share of farmers choroLayer(x = mtq_pencil, var = "shareCS1",            method = "quantile", nclass = 4,           lwd = .7,            legend.values.rnd = 2, legend.pos = "topright",           legend.title.txt = "Share of \nthe population\nworking in\nagriculture (%)")# communes boundariesplot(st_geometry(mtq), lwd = 0.5, add = TRUE)# map layoutlayoutLayer(title="Farmers in Martinique, 2013",             scale = 5, col = "white", coltitle = "black",            author = "cartography_2.1.1.9000",              sources = "INSEE, 2016")Inspired by some ideas and tips exposed in this post (Draw maps like paintings), I used a handwritten font and a background image to produce the following map:The code used to produce all figures in this post is available here.