fgdc_dict: FGDC pattern labeling function/dictionary

View source: R/patterns.R

fgdc_dictR Documentation

FGDC pattern labeling function/dictionary

Description

Generates a labeling function/dictionary based on the built-in fgdc_names dataset that can be used to retrieve the names of patterns based on their pattern numbers/codes as defined in the FGDC Digital Cartographic Standard for Geologic Map Symbolization by the U.S. Geological Survey and the Geologic Data Subcommittee (GDS) of the Federal Geographic Data Committee (FGDC). Like fgdc_names, only patterns with names are included (i.e., patterns 601-733).

Usage

fgdc_dict(clean = TRUE, nomatch = NULL, wrap = NULL)

Arguments

clean

logical. Should the pattern names be cleaned? If TRUE (default), the names will be cleaned to remove strings such as "(2nd option)". If FALSE, the names will be verbatim from the FGDC standard. Note that pattern names may not be unique when this is set to TRUE.

nomatch

character. A string to label values that do not match any name in the dictionary. When NULL (default), the values are kept as-is.

wrap

integer. If not NULL, the pattern names will be wrapped to the specified width (in characters) by insertting line breaks between words using strwrap() (words will not be broken). This can be useful for making long names fit better in legends. If NULL (default), no wrapping is done.

Value

A labeling function that takes a vector x of pattern numbers and returns a character vector of length(x) giving the corresponding pattern names. The function is designed to be used with the labels argument of ggplot2 scales, such as scale_fill_geopattern() and ggpattern::scale_pattern_type_identity().

See Also

FGDC patterns: fgdc_names, geo_pattern(), grid.pattern_geo(), scale_fill_geopattern()

Examples

library(ggplot2)
vals <- c("603", "626", "720", "733")
ggplot(mpg, aes(factor(cyl), fill = vals[factor(cyl)])) +
  geom_bar() +
  scale_fill_geopattern(name = NULL, labels = fgdc_dict())

deeptime documentation built on Nov. 20, 2025, 5:08 p.m.