Skip to contents

Render layers from a spatial data source to a PNG image, applying any styles from the layer_styles table (GPKG) or .qml sidecar files. Runs headless QGIS inside Docker - no QGIS desktop install needed.

Usage

rfp_map_render(
  path,
  path_out = NULL,
  layers = NULL,
  width = 1200L,
  height = 900L,
  image = NULL
)

Arguments

path

Character. Path to a spatial data file (GPKG, GeoJSON, Shapefile) or a directory containing spatial files.

path_out

Character. Output PNG file path. If NULL (default), writes to a tempfile and returns its path.

layers

Character vector. Which layers to render. NULL (default) renders all spatial layers (non-spatial tables are automatically skipped).

width

Integer. Image width in pixels. Default 1200.

height

Integer. Image height in pixels. Default 900.

image

Character or NULL. Docker image for headless QGIS. NULL (default) uses the digest rfp pins, which is the same image its tests and its reference-authoring scripts run, so a render is reproducible rather than following whatever :latest was last re-pushed. Pass a reference to override.

The pinned image is amd64-only, so rfp adds --platform for it; an image rfp knows nothing about is run without one, and you own its platform.

Value

Character - path to the rendered PNG file.

Details

Useful for vignettes (embed rendered maps without requiring QGIS to build), automated testing (visual regression checks), and project previews.

Examples

if (FALSE) { # \dontrun{
# Render a styled GPKG to PNG
png_path <- rfp_map_render("background_layers.gpkg")

# Render specific layers at higher resolution
rfp_map_render(
  "background_layers.gpkg",
  path_out = "preview.png",
  layers = c("lake", "road", "crossings_pscis_assessment"),
  width = 2400,
  height = 1800
)

# Render all spatial files in a directory
rfp_map_render("~/Projects/gis/elk_river_2026/")
} # }