Skip to contents

Returns the raster style registry. Each row names a .qml shipped under inst/extdata/styles/raster/, and style is the key rfp_qgs_raster_add() takes.

Usage

rfp_raster_styles(style = NULL)

Arguments

style

Character. Optional filter - return only this style.

Value

A tibble with columns:

style

style key, used by rfp_qgs_raster_add()

description

human-readable name

label

short name used to build a companion layer's name

renderer

QGIS renderer the .qml carries

companion

style applied as a second layer over the same raster

stretch

from_data, from_data_p2_98, or none - how rfp_qgs_raster_add() sets the renderer's range when the caller does not. Which elements that range is written to depends on the renderer, not on this column

source

path to the .qml, relative to the installed package

Details

Adding a style, or restyling one, is a row and a file - never an edit to a function. That is the same test rfp_form_types() holds itself to.

What is a column and what is not

Only the knobs that vary per project live in the registry or in arguments: the renderer, whether a companion layer is wanted, how the stretch is obtained. Everything that decides the look - the ramp, its stops, class breaks, labels - stays inside the .qml.

The boundary matters because it was crossed once already: gq's registry models around 20 symbology properties against the 73 a QGIS layer can carry, and #17 records that patching that gap field-by-field chases a ghost. A .qml is QGIS's own serialisation and loses nothing.

Pairs are project-only

companion names a second style applied to the same raster as a second layer - turbo elevation under its hillshade. QGIS reads one foo.qml per foo.tif, so a pair cannot be delivered as a sidecar; it exists only when a project is written - rfp_qgs_raster_add(companion = TRUE).

label is the short name that pair is built from: the companion layer is called "<label> - <name>", so dem_turbo on a layer named Elevation brings a Hillshade - Elevation. Only a style that appears in some row's companion needs one; nothing else reads the column, and name_companion = overrides it.

Examples

rfp_raster_styles()
#> # A tibble: 4 × 7
#>   style           description            label renderer companion stretch source
#>   <chr>           <chr>                  <chr> <chr>    <chr>     <chr>   <chr> 
#> 1 dem_turbo       Elevation - turbo ramp Elev… singleb… "dem_hil… from_d… inst/…
#> 2 dem_hillshade   Hillshade relief       Hill… hillsha… ""        none    inst/…
#> 3 habitat_lateral Lateral habitat class… Habi… paletted ""        none    inst/…
#> 4 airphoto_gray   Airphoto - greyscale … Airp… singleb… ""        from_d… inst/…

rfp_raster_styles("dem_turbo")
#> # A tibble: 1 × 7
#>   style     description            label     renderer   companion stretch source
#>   <chr>     <chr>                  <chr>     <chr>      <chr>     <chr>   <chr> 
#> 1 dem_turbo Elevation - turbo ramp Elevation singleban… dem_hill… from_d… inst/…

# the path to hand to rfp_qgs_raster_add(qml = )
rfp_raster_style_path("dem_hillshade")
#> [1] "/home/runner/work/_temp/Library/rfp/extdata/styles/raster/dem_hillshade.qml"