For categorized/graduated layers, returns the field, color values, and
labels suitable for tmap's tm_scale_categorical().
Arguments
- layer_or_reg
Either a layer entry from the registry (e.g.,
reg$layers$lake) or a full registry list when using name-based lookup.- name
Optional layer name for name-based lookup. Accepts
name_qgis_snake(e.g.,"lake") orname_qgis(e.g.,"Crossings - PSCIS assessment"). Normalized to match registry keys.- field
Optional character string to override the classification field name. Useful when data comes from an alternative source with a different column name (e.g., bcfishpass
barrier_statusvs WHSEbarrier_result_code). Seeinst/registry/xref_layers.csvfor known alternatives.
Value
A named list with field, values (named color vector), labels,
widths (named line-width vector for line layers; NULL otherwise), and
dashes (named raw-QGIS-dash vector for classes that are dashed; NULL
otherwise). The dash value is the raw QGIS encoding (named style like
"dash dot", or custom pattern like "0.66;2") — consumers map it to their
backend's line type (e.g. tmap lty = "dashed" for non-NA entries).
Examples
path <- system.file("examples", "mini_registry.json", package = "gq")
reg <- gq_registry_read(path)
# Name-based lookup
cls <- gq_tmap_classes(reg, "road")
cls$field
#> [1] "road_type"
cls$values
#> highway arterial
#> "#c0392b" "#e67e22"
cls$labels
#> [1] "Highway" "Arterial"
cls$widths
#> highway arterial
#> 2.0 1.5
cls$dashes
#> highway arterial
#> NA "0.66;2"
# Object-based (backwards compatible)
cls <- gq_tmap_classes(reg$layers$road)
