Plot a hatched layer with several different patterns. Suitable for b/w print maps.

hatchedLayer(x, pattern = "dot", density = 1, txt = "a", ...)

Arguments

x

an sf object, a simple feature collection. It should be either a POLYGON or a MULTIPOLYGON.

pattern

Desired pattern to use for hatching. Possible values are:

  • Dots: "dot", "text"

  • Lines "diamond","grid","hexagon","horizontal", "vertical", "zigzag","left2right","right2left","circle"

density

of the grid. By default the function uses a grid with a minimum of 10 cells on the shortest dimension of the bounding box. Additionally, it is possible to pass a cellsize value that would feed the st_make_grid underlying function.

txt

for the "text" pattern, that should be a character.

...

Additional graphic parameters (see Details).

Value

When passing mode='sfc' an 'sf' object (either MULTLINESTRING or MULTIPOINT) is returned.

Details

Possible values are:

patternaddcolbgcexpchlwdlty
"dot"xxxxx
"text"xxx
Lines patternsxxxx

See also

Author

dieghernan, https://github.com/dieghernan/

Examples

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
par(mar=c(1,1,1,1))
hatchedLayer(mtq, "dot")
title("dot")

plot(st_geometry(mtq), border = NA, col="grey80")
hatchedLayer(mtq, "text", txt = "Y", add=TRUE)
title("text")

hatchedLayer(mtq, "diamond", density = 0.5)
plot(st_union(st_geometry(mtq)), add = TRUE)
title("diamond")

hatchedLayer(mtq, "grid", lwd = 1.5)
title("grid")

hatchedLayer(mtq, "hexagon", col = "blue")
title("hexagon")

hatchedLayer(mtq, "horizontal", lty = 5)
title("horizontal")

hatchedLayer(mtq, "vertical")
title("vertical")

hatchedLayer(mtq, "left2right")
title("left2right")

hatchedLayer(mtq, "right2left")
title("right2left")

hatchedLayer(mtq, "zigzag",cellsize=5000)
title("zigzag")

hatchedLayer(mtq, "circle")
title("circle")