Skip to contents

The viz_clipPath function creates an SVG clipPath definition and adds it to the SVG defs. It returns a reference usable in SVG styling (e.g. url(#id)). WARNING: the clipPath is global to the web page, not only the map.

Usage

viz_clipPath(map, id = NULL, datum = list(type = "Sphere"), permanent = FALSE)

Arguments

map

A geoviz map created with viz_create.

id

character. Optional. Unique clipPath id.

datum

object. Optional. Geometry used for clipping (default list(type = "Sphere")).

permanent

logical or character. Optional. Whether the clipPath is static (default FALSE).

Examples

library(sf)
world <- st_read(
  system.file("gpkg/world.gpkg", package = "geoviz"),
  quiet = TRUE
)
aus <- world[world$ISO3 == "AUS", ]

viz_create(margin = 5, projection = "meractor") |>
viz_clipPath(id = "ausclip", datum = aus) |>
viz_tile(url = "worldStreet", clipPath = "url(#ausclip)") |>
viz_render()