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 = "qgis/qgis:latest"
)

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. Docker image for headless QGIS. Default "qgis/qgis:latest".

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/")
} # }