knitr::opts_chunk$set(collapse = TRUE, out.width = "100%", dev.args = list(png = list(type = "cairo-png")),
                      fig.width = 7, fig.height = 6, fig.align = "center")
In 2006, the [U.S. Geological Survey](https://www.usgs.gov/) and the [Geologic Data Subcommittee](https://ngmdb.usgs.gov/fgdc_gds/index.php) of the [Federal Geographic Data Committee](https://www.fgdc.gov/) established the [Digital Cartographic Standard for Geologic Map Symbolization](https://ngmdb.usgs.gov/fgdc_gds/geolsymstd.php). This is the National Standard for the digital cartographic representation of geologic map features, including line symbols, point symbols, colors, and patterns. The standard patterns that are put forth in this document are included in **deeptime** ([thanks to the work that Daven Quinn put in to extracting them as SVGs](https://github.com/davenquinn/geologic-patterns/)). Let's explore the functionality that **deeptime** has to retrieve and utilize these patterns. Let's first load the packages we'll need: wzxhzdk:1 wzxhzdk:2 ## Stratigraphic columns The [**rmacrostrat**](https://rmacrostrat.palaeoverse.org/) package allows users to access the Macrostrat API, which includes various geological data (e.g., lithostratigraphic units) and definitions/metadata associated with those data. The package includes a number of [vignettes](https://rmacrostrat.palaeoverse.org/articles/) that walk through how to retrieve and visualize various types of data from the database. Here, we're going to be plotting a stratigraphic column for the San Juan Basin, a large structural depression which spans parts of New Mexico, Colorado, Utah, and Arizona. The details about downloading this data are thoroughly presented in [this **rmacrostrat** vignette](https://rmacrostrat.palaeoverse.org/articles/stratigraphic-column.html). For the purposes of this **deeptime** vignette, we'll skip ahead and download the unit-level stratigraphic data for this basin during the Cretaceous: wzxhzdk:3 ### Plot stratigraphic column We now have information for each of the 17 Cretaceous geologic units contained within the San Juan Basin, including the age of the top and bottom of each, which is what we will use to plot our stratigraphic column. We'll follow the **rmacrostrat** vignette to plot the stratigraphic column: wzxhzdk:4 ### Use stratigraphic patterns Isn't that snazzy! You'll see that we used the colors that come straight from Macrostrat (i.e., the "color" column) to visualize the different units. Presumably these colors represent something about the different lithologies of the units. However, we could also represent these lithologies with our standardized FGDC patterns. First, we'll need to get the lithology definitions from Macrostrat, which includes the FGDC pattern codes: wzxhzdk:5 In this output, the "fill" column corresponds to the FGDC pattern code for each lithology. Now, we need to figure out the lithology of each of our San Juan units. However, you'll notice that some units have multiple lithologies: wzxhzdk:6 That's a lot of different lithologies for this single unit! We could theoretically represent all of the lithologies, but let's just go ahead and extract the primary lithology, or the one with the highest "prop" value (i.e., proportion of unit): wzxhzdk:7 Now that we've assigned a primary lithology to each unit, we can assign an FGDC pattern code to each unit: wzxhzdk:8 Excellent, we now have a pattern code for each unit! Now we can go ahead and use these instead of the colors for the fills of the units. In order to convert the codes to visual patterns, we'll need to move the `fill` argument to a call to `aes()` and we'll need to add a call to `scale_fill_geopattern()`: wzxhzdk:9 ### Further customization If you use `scale_fill_geopattern()`, the patterns are used with the default parameters (e.g., line color, background color, and scale). However, if you'd like to customize how the patterns look, you can use the `geom_` functions from the [**ggpattern**](https://trevorldavis.com/R/ggpattern/) package (e.g., `geom_rect_pattern()`) and use the "geo" `pattern`. Once you have implemented this, any of the following ggplot2 aesthetics can be used to tweak the patterns. _Note that the defaults for these two methods are often different:_ | aesthetic | description | `scale_fill_geopattern()` default | ggpattern default | |--------------------------|-----------------------------------------------|-----------|----------------------------------------| | pattern\_type | Code for the FGDC pattern to use | "101" | "101" | | pattern\_color | Color used for strokes and points | original color | "grey20" | | pattern\_fill | Color used to fill various closed shapes (e.g., circles) in the pattern | original color | "grey80" | | pattern\_alpha | Alpha transparency for pattern | 1 | 1 | | pattern\_scale | Scale of the pattern (higher values zoom in on pattern) | 2 | 1 | | fill | Background color | "white" | "white" | For the pattern code (i.e., `pattern\_type`), see the "pattern numbers" in the [full pattern chart](https://ngmdb.usgs.gov/fgdc_gds/geolsymstd/fgdc-geolsym-patternchart.pdf) for the full list of options. Daven Quinn has also assembled more accessible documentation of the [map patterns/codes](https://davenquinn.com/projects/geologic-patterns/#pattern-reference) and [lithology patterns/codes](https://davenquinn.com/projects/geologic-patterns/#series-600). `def_lithologies()` can also be used to look up pattern codes for various lithologies (see the "fill" column). Note that codes associated with color variants (e.g., "101-M") are supported but will result in the default color variant instead (usually black and white). Most, if not all, color variants can be recreated by adjusting the color, fill, and background of the pattern. Let's try increasing the scale of the patterns in our stratigraphic column. We'll need to switch to using `geom_rect_pattern()`. Since we are specifying the patterns within an `aes()` call, we can use `scale_pattern_type_identity()` to use those raw pattern codes: wzxhzdk:10 Oh no! This is a good example of how the defaults change between the two methods. We can easily fix this by specifying our own defaults: wzxhzdk:11 There we go, now the patterns are more zoomed in! Hmm...now it looks a little boring. Let's go ahead and bring back those colors from before. We'll make both the background color (`fill`) and the pattern fill color (`pattern_fill`) based on the "color" column: wzxhzdk:12 Well isn't that a nice looking visualization of the stratigraphic column!


willgearty/deeptime documentation built on Dec. 24, 2024, 2:03 a.m.