Skip to contents

The viz_sketch function renders a spatial dataframe as hand-drawn (sketchy) SVG shapes. It uses SVG filters (feTurbulence and feDisplacementMap) to simulate a pencil-like rendering style.

Usage

viz_sketch(
  map,
  data = NULL,
  id = NULL,
  fill = "none",
  stroke = "#000",
  strokeWidth = 1,
  simplify = NULL,
  baseFrequency = 0.03,
  feDisplacementMap = 5,
  fillStyle = "dashed",
  roughness = 5,
  hachureGap = 3,
  bowing = 30,
  fillWeight = 0.12,
  ...
)

Arguments

map

A geoviz map created with viz_create.

data

object. Optional. A spatial data frame (or equivalent geometry input).

id

character. Optional. Unique layer id (auto-generated if not provided).

fill

character. Optional. Fill color (default "none").

stroke

character. Optional. Stroke color (default "#000").

strokeWidth

numeric. Optional. Stroke width (default 1).

simplify

numeric or vector or logical. Optional. Geometry simplification

baseFrequency

numeric. Optional. Base frequency of the turbulence filter (default 0.03). Controls noise density.

feDisplacementMap

numeric. Optional. Displacement intensity of the sketch effect (default 5).

fillStyle

character. Optional. Fill style (default "dashed").

roughness

numeric. Optional. Roughness level (reserved for future use, default 5).

hachureGap

numeric. Optional. Gap between hachure lines (reserved, default 3).

bowing

numeric. Optional. Line bowing effect (reserved, default 30).

fillWeight

numeric. Optional. Fill stroke weight (reserved, default 0.12).

...

Additional SVG attributes (e.g. strokeDasharray, opacity, strokeLinecap, etc.).

Examples

library(sf)

world <- st_read(
  system.file("gpkg/world.gpkg", package = "geoviz"),
  quiet = TRUE
)

viz_create(width = 750, background = "white", projection = "EqualEarth") |>
viz_sketch(data = world, stroke = "#38896F", strokeWidth = 1) |>
viz_render()