Learn R Programming

cartography (version 2.4.2)

hatchedLayer: Hatched Layer

Description

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

Usage

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:

pattern add col bg cex pch lwd lty
"dot" x x x x x
"text" x x x

See Also

legendHatched

Examples

Run this code
# NOT RUN {
library(sf)
mtq <- st_read(system.file("gpkg/mtq.gpkg", package = "cartography"))
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")
# }

Run the code above in your browser using DataLab