The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

Title: Stratigraphic Data Processing and Section Plots
Version: 0.1.1
Description: Data processing and generating stratigraphic sections for volcanic deposits and tephrastratigraphy. Package was developed for studies on Alaska volcanoes ("av") where stratigraphic ("strat") figures are needed for interpreting eruptive histories, but the methods are applicable to any sediment stratigraphy project. Plotting styles inspired by "SedLog" (Zervas et al. 2009) <doi:10.1016/j.cageo.2009.02.009> but with more customizable outputs and flexible data input based on best practice recommendations for the tephra community (Wallace et al. 2022) <doi:10.1038/s41597-022-01515-y>.
License: CC0
Copyright: This software is in the public domain because it contains materials that originally came from the United States Geological Survey, an agency of the United States Department of the Interior.
BugReports: https://code.usgs.gov/vsc/tephra/tools/avstrat/-/issues
Encoding: UTF-8
RoxygenNote: 7.3.3
Imports: dplyr, tidyr, ggplot2 (≥ 4.0), grid, patchwork, rlang, shiny, leaflet
Suggests: knitr, readxl, rmarkdown, testthat (≥ 3.0.0), tibble, withr
Depends: R (≥ 4.1.0)
LazyData: true
Config/testthat/edition: 3
VignetteBuilder: knitr
NeedsCompilation: no
Packaged: 2026-02-02 05:49:06 UTC; mloewen
Author: Matthew Loewen ORCID iD [aut, cre]
Maintainer: Matthew Loewen <mloewen@usgs.gov>
Repository: CRAN
Date/Publication: 2026-02-04 18:20:02 UTC

Required stratigraphic categories

Description

These are the canonical categories that all stratigraphic palettes must cover. They are used by validate_stratpal() to ensure palettes are complete.

Usage

.required_strat_categories

Format

An object of class character of length 30.


Internal list of stratigraphic palettes

Description

This list collects all palettes so they can be looked up by name. Add new palettes here as you create them.

Usage

.stratpalettes

Format

An object of class list of length 2.


Add standardized depth information to stratigraphic layer data

Description

add_depths() takes a data frame of stratigraphic layer information and calculates standardized thickness and depth values. It ensures required columns are present, converts thickness and depth units to centimeters, derives a plotting thickness, and computes top, bottom, and middle depths for each layer within a stratigraphic section. The function is designed to handle input where layers are defined either by order and thickness or with absolute start and stop depth values.

Usage

add_depths(df)

Arguments

df

A data frame containing stratigraphic layer information. The following columns are required depending on the method:

Always required

  • stratsection_name: Unique identity of the section (repeated for each layer).

  • stratlayer_name: Unique identity of the layer.

  • stratmeasuremethod: One of "order and thickness" or "start and stop depth".

  • stratlayer_order_start_at_top: Logical, does ordering start at the top (TRUE) or bottom (FALSE)? For "start and stop depth", this defines if the reference "depth" is the top or bottom of the section.

If stratmeasuremethod == "order and thickness"

  • stratlayer_order: Integer order of layers within the section.

  • thickness_units: One of "meters", "centimeters", "millimeters".

  • At least one of thickness_typical, thickness_min, or thickness_max.

If stratmeasuremethod == "start and stop depth"

  • depth_units: One of "meters", "centimeters", "millimeters".

  • depth_top: Absolute depth of the top of the layer.

  • depth_bottom: Absolute depth of the bottom of the layer.

Other columns are carried through unchanged. Missing expected columns are added automatically and filled with NA.

Details

The function groups data by stratsection_name and orders layers according to stratlayer_order_start_at_top. Depths are computed cumulatively if only thickness is provided, or taken directly from absolute depth columns if available.

Value

A tibble with the original data plus:

Examples

# Example data is included with the package
data("example_data_strat", package = "avstrat")

# Order + thickness method (section "fake1")
df1 <- subset(example_data_strat, stratsection_name == "fake1")
add_depths(df1)

# Start/stop depth method (section "fake3")
df2 <- subset(example_data_strat, stratsection_name == "fake3")
add_depths(df2)


Reformat stratigraphic layer data for polygon plotting

Description

add_layer_width() reshapes stratigraphic layer grainsize data into a "long" format suitable for plotting polygons in a stratigraphic section diagram. It constructs left/right grain size boundaries, gathers them into long format, assigns depth coordinates, and converts grain size text labels into numeric values for plotting with ggstrat().

Usage

add_layer_width(df, grainsize_direction = c("increasing", "decreasing"))

Arguments

df

A data frame containing stratigraphic layer information. The following columns are required:

  • stratsection_name: Unique identity of the section (repeated for each layer).

  • stratlayer_name: Unique identity of the layer.

  • Depth_top, Depth_bottom: Depths in centimeters, as returned by add_depths().

  • grainsize_top: Grain size at the top of the layer.

  • grainsize_bottom: Grain size at the bottom of the layer.

Grain size values must be chosen from the validated list (White & Houghton, 2006, Geology 34:677–680):

  • "clay" (<1/256 mm)

  • "silt" (1/256-1/16 mm)

  • "very fine sand/ash" (1/16-1/8 mm)

  • "fine sand/ash" (1/8-1/4 mm)

  • "medium sand/ash" (1/4-1/2 mm)

  • "coarse sand/ash" (1/2-1 mm)

  • "very coarse sand/ash" (1-2 mm)

  • "granule/fine lapilli" (2-4 mm)

  • "pebble/medium lapilli" (4-16 mm)

  • "cobble/coarse lapilli" (1.6-6.4 cm)

  • "blocks/bombs/boulders" (>6.4 cm)

  • NA (no data)

Several legacy abbreviations (e.g. "vca", "vcs") are currently accepted but may be deprecated in future versions.

grainsize_direction

Character string, one of "increasing" or "decreasing". Controls the numeric mapping of grain sizes:

  • "increasing" (default): clay/silt = 1, ..., blocks/bombs/boulders = 10.

  • "decreasing": clay/silt = 10, ..., blocks/bombs/boulders = 1.

Increasing will show coarser units as bigger polygons (more prominent) which is espeically useful for emphasizing more energentic volcanic deposits. Decreasing will show finer (typically more resistive) units as bigger which may better match observed erosional profiles.

Value

A tibble in long format with original data plus:

Examples

library(dplyr)
library(tidyr)
df <- tidyr::tibble(
stratlayer_order = c(1,2),
grainsize_top = c("clay", "coarse sand/ash"),
grainsize_bottom = c( "silt", "medium sand/ash"),
Depth_top = c(0, 10),
Depth_bottom = c(10, 20)
)
add_layer_width(df)


Example stratigraphic data from individual tables

Description

A dataset created by loading example inputs with load_stratdata_indiv(). This demonstrates the structure of stratigraphic data when stations, sections, layers, and samples are provided as separate tables and then merged. It shares many column definitions with example_data_strat but contains a reduced set of fields.

Usage

example_data_indiv

Format

example_data_indiv

A data frame with 244 rows and 23 columns:

stratsection_name

Character. Name/identifier of the stratigraphic section.

stratlayer_name

Character. Name/identifier of the stratigraphic layer.

stratlayer_desc

Character. Free‑text description of the layer.

stratlayer_order

Integer. Order of the layer within the section.

thickness_units

Character. Units for thickness (e.g., "millimeters", "centimeters", "meters").

thickness_typical

Numeric. Typical thickness of the layer.

thickness_min

Numeric. Minimum thickness of the layer.

thickness_max

Numeric. Maximum thickness of the layer.

depth_units

Character. Units for depth (see thickness_units).

depth_top

Numeric. Absolute depth to the top of the layer.

depth_bottom

Numeric. Absolute depth to the bottom of the layer.

layer_type

Character/Factor. Lithology or depositional type of the layer (e.g., "tephra fall", "soil").

stratlayer_color

Character. Color description.

grainsize_top

Numeric/Character. Grain size at the top of the layer.

grainsize_bottom

Numeric/Character. Grain size at the bottom of the layer.

volcano_name

Character. Source volcano name. If multiple, separated by "|".

station_id

Character. Station identifier (links back to station metadata).

stratmeasuremethod

Character. Method used for stratigraphic measurement.

stratlayer_order_start_at_top

Logical. Whether ordering starts at the top.

Latdd

Numeric. Latitude in decimal degrees.

Longdd

Numeric. Longitude in decimal degrees.

stratlayer_sample

Character. Collapsed sample identifiers per layer, separated by "|".

SampleID

List. Nested list column of sample IDs per layer.

See Also

example_data_strat for a more complete dataset including additional descriptive fields.


Example GeoDIVA forms data

Description

A dataset of forms loaded with load_geodiva_forms(). Useful for demonstrating plotting and analysis functions in this package.

Usage

example_data_strat

Format

example_data_strat

A data frame with 244 rows and 39 columns:

stratsection_name

Character. Name/identifier of the stratigraphic section.

stratlayer_name

Character. Name/identifier of the stratigraphic layer.

date_described

Date. Date the section was described.

date_described_timezone

Character. Time zone of the description date.

stratlayer_desc

Character. Free‑text description of the layer.

stratlayer_order

Integer. Order of the layer within the section.

thickness_units

Character. Units for thickness (e.g., "millimeters", "centimeters", "meters").

thickness_typical

Numeric. Typical thickness of the layer.

thickness_min

Numeric. Minimum thickness of the layer.

thickness_max

Numeric. Maximum thickness of the layer.

depth_units

Character. Units for depth (see thickness_units).

depth_top

Numeric. Absolute depth to the top of the layer.

depth_bottom

Numeric. Absolute depth to the bottom of the layer.

depth_uncertainty_top

Numeric. Uncertainty in top depth.

depth_uncertainty_bottom

Numeric. Uncertainty in bottom depth.

layer_type

Character/Factor. Lithology or depositional type of the layer (e.g., "tephra fall", "soil").

stratlayer_color

Character. Color description.

grainsize_top

Numeric/Character. Grain size at the top of the layer.

grainsize_bottom

Numeric/Character. Grain size at the bottom of the layer.

stratlayer_grading

Character. Grading description (e.g. normal, reverse).

contact_lower

Character. Description of the lower contact.

contact_upper

Character. Description of the upper contact.

stratlayer_sorting

Character. Sorting description.

stratlayer_support

Character. Support description (matrix or clast).

tephra_concentration

Numeric/Character. Tephra concentration.

stratlayer_unit

Character. Stratigraphic unit designation.

tephra_name

Character. Formal tephra name.

tephra_guess

Character. Tentative tephra identification.

volcano_name

Character. Source volcano name. If multiple source volcanoes separated by "|".

eruption_name

Character. Source eruption name.

stratlayer_sample

Character. Sample identifier. If multiple samples separated by "|".

station_id

Character. Station identifier.

stratmeasuremethod

Character. Method used for stratigraphic measurement.

stratlayer_order_start_at_top

Logical. Whether ordering starts at the top.

section_notes

Character. Free‑text notes about the section.

Latdd

Numeric. Latitude in decimal degrees.

Longdd

Numeric. Longitude in decimal degrees.

LocationDesc

Character. Location description.

SampleID

List. Nested list column of sample IDs per layer.

Source

<doi.org/10.14509/31084>

<doi.org/10.14509/31090>


Extract unnested samples with stratigraphic depths

Description

extract_sample_depths() takes a stratigraphic dataset that has already been merged (e.g. from load_geodiva_forms() or load_stratdata_indiv()) and applies add_depths() to compute absolute depths. It then expands a nested sample column (by default "SampleID") so that each sample is represented as its own row, and drops rows where the chosen column is missing. Optionally, you can strip away all other layer metadata and return only the sample IDs and depth columns. Can be used on any nested or unested column.

Usage

extract_sample_depths(
  strat_data,
  sample_column = "SampleID",
  remove_layer_metadata = FALSE
)

Arguments

strat_data

A data frame ready for applying add_depths(), containing "SampleID" or another column you want to expand to sample-level rows.

sample_column

A string giving the name of the column to extract and unnest. Defaults to "SampleID".

remove_layer_metadata

Logical. If TRUE, only the selected sample column and the depth columns (Depth_top, Depth_middle, Depth_bottom) are returned. Defaults to FALSE.

Value

A data frame with one row per sample, including the depth information and associated layer metadata (unless remove_layer_metadata = TRUE).

Examples

# Default: expand the SampleID column
extract_sample_depths(example_data_strat)

# Expand a different column (here "stratlayer_sample")
extract_sample_depths(example_data_strat, sample_column = "stratlayer_sample")

# Return only SampleID and depth columns
extract_sample_depths(example_data_strat, remove_layer_metadata = TRUE)

Plot a grainsize-depth stratigraphic section

Description

Uses ggplot2 to create a grainsize vs. depth stratigraphic section plot.

Usage

ggstrat(
  df,
  section_name,
  grainsize_direction = c("increasing", "decreasing"),
  grainsize_labs = gs_volc_abbr,
  use_theme = NULL,
  xlim = c(-1, 10),
  ylim = NULL,
  depth_units = c("cm", "m"),
  ybreaks = 7,
  layer_fill = "layer_type",
  layer_fill_color = "stratpal_rpg",
  layer_border_color = "black",
  layer_border_linewidth = 0.2
)

Arguments

df

A data frame containing stratigraphic data. Must include columns stratsection_name, stratlayer_order, grainsize, depth, and stratlayer_type.

section_name

Character string giving the section name to filter "stratsection_name".

grainsize_direction

Character string, one of "increasing" or "decreasing". Controls the numeric mapping of grain sizes:

  • "increasing" (default): clay/silt = 1, ..., blocks/bombs/boulders = 10.

  • "decreasing": clay/silt = 10, ..., blocks/bombs/boulders = 1.

Increasing will show coarser units as bigger polygons (more prominent) which is espeically useful for emphasizing more energentic volcanic deposits. Decreasing will show finer (typically more resistive) units as bigger which may better match observed erosional profiles.

grainsize_labs

Character vector of labels for the x-axis. Several predefined options are available:

  • gs_volc_abbr: Volcanic grainsize abbreviations (default).

  • gs_sed_abbr: Sedimentary grainsize abbreviations.

  • gs_volc_names: Volcanic grainsize full names.

  • gs_sed_names: Sedimentary grainsize full names.

  • gs_numeric: Numeric grainsize labels.

use_theme

A ggplot2 theme object to apply to the plot, e.g., "theme_avstrat".

xlim

Numeric vector of length 2 giving x-axis limits.

ylim

Numeric vector of length 2 giving y-axis limits (optional).

depth_units

Units to use for depth (y-axis) scale, either "cm" (default) or "m".

ybreaks

Number of breaks on the y-axis.

layer_fill

Character string naming the column to use for fill. If using anything other than "layer_type" from the template, will need to make a new palette.

layer_fill_color

Palette object to use for fill colors.

layer_border_color

Border color for polygons.

layer_border_linewidth

Border line width for polygons.

Value

A ggplot object

Examples

example_data_strat |>
 add_depths() |>
 ggstrat(section_name = "21LSHD02")

Bulk save stratigraphic plots for all uploaded sections

Description

Generate and save a series of stratigraphic plots, one per unique stratigraphic section in the input data frame. The user can supply any plotting function that returns a ggplot object (e.g. one of the package's plotting functions, or a custom function).

Usage

ggstrat_bulk_save(
  df,
  plotfunction = ggstrat,
  outdir = NULL,
  file_type = "png",
  dpi = 300,
  width = 4,
  height = 8,
  units = "in",
  ask = TRUE,
  ...
)

Arguments

df

A data frame containing stratigraphic data. Must include columns stratsection_name, and any other variables needed for the plotfunction, such as: stratlayer_order, grainsize, depth, and stratlayer_type.

plotfunction

A function that generates a plot for a single section. It should accept at least two arguments: the full data frame (df) and a section identifier (stratsection_name). Defaults to ggstrat().

outdir

Directory where plots will be saved. Suggest supplying a name such as "StratSectionsPlotted", will create directory if it does not exist.

file_type

File extension for saved plots (e.g. "png", "pdf"). Defaults to "png".

dpi

Plot resolution in dots per inch. Can be a numeric value (e.g. 300) or one of "screen", "print", or "retina". Defaults to 300.

width

Plot width passed to ggplot2::ggsave(). Defaults to 4.

height

Plot height passed to ggplot2::ggsave(). Defaults to 8.

units

Units for width and height. One of "in", "cm", or "mm". Defaults to "in".

ask

Logical. If TRUE (default) and running interactively, the function will prompt the user to confirm before generating and saving all plots.

...

Additional arguments passed on to plotfunction.

Value

Invisibly returns NULL. Called for its side effect of saving plot files to disk.

Examples


# Save plots for each section using the default ggstrat() function
td <- tempdir()
ggstrat_bulk_save(example_data_strat, outdir = td)

# Save plots using a different plotting function
ggstrat_bulk_save(example_data_strat,
                  plotfunction = ggstrat_column,
                  outdir = td)

# Save plots with higher resolution
ggstrat_bulk_save(example_data_strat,
                  outdir = td,
                  dpi = 600)

# Optional cleanup
unlink(list.files(td, full.names = TRUE))


Plot a simple stratigraphic column

Description

Uses ggplot2 to create a simple depth-only stratigraphic section plot with no variable mapped to the x-axis. Each layer is drawn as a fixed-width rectangle.

Usage

ggstrat_column(
  df,
  section_name,
  use_theme = NULL,
  ylim = NULL,
  depth_units = c("cm", "m"),
  ybreaks = 7,
  layer_fill = "layer_type",
  layer_fill_color = "stratpal_rpg",
  layer_border_color = "black",
  layer_border_linewidth = 0.2
)

Arguments

df

A data frame containing stratigraphic data. Must include columns stratsection_name, stratlayer_order, grainsize, depth, and stratlayer_type.

section_name

Character string giving the section name to filter "stratsection_name".

use_theme

A ggplot2 theme object to apply to the plot, e.g., "theme_avstrat".

ylim

Numeric vector of length 2 giving y-axis limits (optional).

depth_units

Units to use for depth (y-axis) scale, either "cm" (default) or "m".

ybreaks

Number of breaks on the y-axis.

layer_fill

Character string naming the column to use for fill. If using anything other than "layer_type" from the template, will need to make a new palette.

layer_fill_color

Palette object to use for fill colors.

layer_border_color

Border color for polygons.

layer_border_linewidth

Border line width for polygons.

Value

A ggplot object showing a schematic stratigraphic column.

Examples

example_data_strat |>
  ggstrat_column(section_name = "21LSHD02")

Plots text lables alongside a stratigraphic section

Description

Uses ggplot2 to plot any character column associated with stratigraphic data such as SampleID at the correct depths for their corresponding layers. Connecting lines extend to the left of the plot to point to plotted layers. It is designed to be combined with a stratigraphic section plot created by ggstrat() using the patchwork::patchwork framework for arranging multiple ggplot objects.

Usage

ggstrat_label(
  df,
  section_name,
  use_theme = NULL,
  label = "stratlayer_sample",
  ylim = NULL,
  ybreaks = 7
)

Arguments

df

A data frame containing stratigraphic data. Must include columns stratsection_name, stratlayer_order, grainsize, depth, and the column specified by layer_fill.

section_name

Character string giving the section name to filter "stratsection_name".

use_theme

A ggplot2 theme object to apply to the plot, e.g., "theme_avstrat".

label

Character strin gnaming the column to use for labels. Default is "SampleID".

ylim

Numeric vector of length 2 giving y-axis limits (optional).

ybreaks

Number of breaks on the y-axis.

Value

A ggplot object showing SampleIDs plotted by depth in section.

Examples

# Example 1: Basic usage
example_data_strat |>
  ggstrat_label(section_name = "21LSHD02",
              label = "SampleID")

# Example 2: Combine with a stratigraphic section plot using patchwork
if (requireNamespace("patchwork", quietly = TRUE)) {
  stratsection <- example_data_strat |>
    ggstrat(section_name = "21LSHD02")

  samples <- example_data_strat |>
    ggstrat_label(section_name = "21LSHD02",
              label = "SampleID")

  stratsection + samples
}


A combined grainsize-depth and sample label stratigraphic plot

Description

Combines a grainsize–depth plot and sample label plot into a single composite figure using the patchwork::patchwork framework. The two plots are aligned and legends are collected at the bottom.

Usage

ggstrat_samples(
  df,
  section_name,
  label = "stratlayer_sample",
  use_theme = NULL,
  ylim = NULL,
  depth_units = c("cm", "m"),
  ybreaks = 7
)

Arguments

df

A data frame containing stratigraphic data. Must include columns stratsection_name, stratlayer_order, grainsize, depth, stratlayer_type, and SampleID.

section_name

Character string giving the section name to filter "stratsection_name".

label

Character strin gnaming the column to use for labels. Default is "SampleID".

use_theme

A ggplot2 theme object to apply to the plot, e.g., "theme_avstrat".

ylim

Numeric vector of length 2 giving y-axis limits (optional).

depth_units

Units to use for depth (y-axis) scale, either "cm" (default) or "m".

ybreaks

Number of breaks on the y-axis.

Value

A patchwork/ggplot object combining the stratigraphic plot and sample labels. This object can be further modified with ggplot2::theme() or additional patchwork operators.

Examples

example_data_strat |>
  ggstrat_samples(section_name = "21LSHD02")

Load stratigraphic data from GeoDIVA upload forms

Description

load_geodiva_forms() processes and cleans stratigraphic data from GeoDIVA upload forms, specifically a form that includes Station and Sample data and another form that includes the Layer data. It merges these datasets, resolves any conflicts in key fields, and prepares a consolidated dataset for further analysis. The function also extracts and, optionally, prints a list of unique stratigraphic sections.

Usage

load_geodiva_forms(station_sample_upload, layer_upload, verbose = TRUE)

Arguments

station_sample_upload

data frame created from uploaded GeoDIVA format Station/Sample upload sheet, usually uploaded with readxl::read_xlsx() linked to filepath.

layer_upload

data frame created from uploaded GeoDIVA format Layers upload sheet, usually uploaded with readxl::read_xlsx() linked to filepath.

verbose

Logical. If TRUE (default), prints a message listing the imported stratigraphic sections. Set to FALSE to suppress console output.

Value

A data frame containing the merged and cleaned stratigraphic data, ready for further analysis.

Examples

# Locate the example Excel files shipped with the package
path_samples <- system.file("extdata", "example_samples_stations_upload_2024.xlsx",
  package = "avstrat"
)
path_layers <- system.file("extdata", "example_layers_upload_2024.xlsx",
  package = "avstrat"
)

# Read them with readxl
library(readxl)
  station_sample_upload <- readxl::read_xlsx(path_samples, sheet = "Data")
  layer_upload <- readxl::read_xlsx(path_layers, sheet = "Data")

  result <- load_geodiva_forms(station_sample_upload, layer_upload)
  head(result)  # result is a data frame

Load stratigraphic data from individual tables

Description

load_stratdata_indiv() loads necessary data for avstrat from separate station (location), section (section metadata), stratlayer, and sample data. Allows upload of smaller number of tables if data are already joined together (e.g., stations-sections combined, or layers-samples combined). The function also extracts and, optionally, prints a list of unique stratigraphic sections.

Usage

load_stratdata_indiv(
  stations_upload,
  sections_upload,
  layers_upload,
  samples_upload = NULL,
  verbose = TRUE
)

Arguments

stations_upload

A data frame with "station" metadata. The following columns are required in order to work with avstrat functions:

  • station_id: UniqueID for the station.

  • latdd: Location in decimal degrees, in WGS84 datum.

  • longdd: Longitude in decimal degrees, in WGS84 datum.

sections_upload

A data frame with "section" metadata (point to same file as station_upload if already joined). The following columns are required in order to work with avstrat functions:

  • station_id: UniqueID for the station, must match an existing value in station_upload.

  • stratsection_name: Unique identity of the section.

  • stratmeasuremethod: One of "order and thickness" or "start and stop depth".

  • stratlayer_order_start_at_top: Logical, does ordering start at the top (TRUE) or bottom (FALSE)? For "start and stop depth", this defines if the reference "depth" is the top or bottom of the section.

layers_upload

A data frame with "layer" metadata. The following columns are required in order to work with avstrat functions:

  • stratsection_name: Unique identity of the section, must match an existing value in section_upload.

  • stratlayer_name: Unique identifier for the layer.

  • layer_type: A character value from a list for plotting default layer symbols (color). If not provided, plotting functions will need to override default layer_fill mapping. Must be chosen from a validated list:

    • volcanic

    • ⁠tephra fall⁠

    • lava

    • intrusion

    • tuff

    • sediment

    • soil

    • peat

    • lacustrine

    • fluvial

    • eolian

    • diamict

    • clay

    • ⁠pyroclastic density current⁠

    • ⁠pyroclastic surge⁠

    • ⁠pyroclastic flow⁠

    • ⁠mass wasting⁠

    • ⁠debris flow⁠

    • lahar

    • landslide

    • ⁠hyperconcentrated flow⁠

    • ⁠debris avalanche⁠

    • ⁠frozen water⁠

    • ice

    • snow

    • ⁠dirty snow⁠

    • plant

    • rock

    • other

    • undifferentiated/undescribed

  • grainsize_top: Grain size at the top of the layer.

  • grainsize_bottom: Grain size at the bottom of the layer.

Grain size values must be chosen from the validated list (White & Houghton, 2006, Geology 34:677–680):

  • "clay" (<1/256 mm)

  • "silt" (1/256-1/16 mm)

  • "very fine sand/ash" (1/16-1/8 mm)

  • "fine sand/ash" (1/8-1/4 mm)

  • "medium sand/ash" (1/4-1/2 mm)

  • "coarse sand/ash" (1/2-1 mm)

  • "very coarse sand/ash" (1-2 mm)

  • "granule/fine lapilli" (2-4 mm)

  • "pebble/medium lapilli" (4-16 mm)

  • "cobble/coarse lapilli" (1.6-6.4 cm)

  • "blocks/bombs/boulders" (>6.4 cm)

  • NA (no data)

If stratmeasuremethod == "order and thickness"

  • stratlayer_order: Integer order of layers within the section.

  • thickness_units: One of "meters", "centimeters", "millimeters".

  • thickness_typical: Numeric value of the typical thickness of a layer.

  • thickness_min: Numeric value of the minimum thickness of a layer.

  • thickness_max: Numeric value of the maximum thickness of a layer. If stratmeasuremethod == "start and stop depth"

  • depth_units: One of "meters", "centimeters", "millimeters".

  • depth_top: Absolute depth of the top of the layer.

  • depth_bottom: Absolute depth of the bottom of the layer.

samples_upload

A data frame with "sample" metadata.

  • stratlayer_name: Unique identifier for the layer, must match an existing value in layer_upload.

  • SampleID: Unique identifier for the sample.

verbose

Logical. If TRUE (default), prints a message listing the imported stratigraphic sections. Set to FALSE to suppress console output.

Value

A data frame of layers joined with section and station metadata, plus collapsed sample information:

Examples

# Locate the example Excel files shipped with the package
path <- system.file("extdata", "example_inputs.xlsx",
  package = "avstrat"
)

# Read them with readxl
library(readxl)
  stations <- readxl::read_xlsx(path, sheet = "stations")
  sections <- readxl::read_xlsx(path, sheet = "sections")
  layers <- readxl::read_xlsx(path, sheet = "layers")
  samples <- readxl::read_xlsx(path, sheet = "samples_layer")

  load_stratdata_indiv(stations_upload = stations,
                       sections_upload = sections,
                       layers_upload = layers,
                       samples_upload = samples)


Launch the interactive map with stratigraphy plots

Description

This function launches a Shiny app that displays an interactive map locations with stratigraphic data. If you click on a station it will generate a stratigraphic plot with the plotting function of your choice (default is ggstrat_samples()). You can also adjust the height of the plot using the slider below the map.

Usage

run_ggstrat_app(df, plot_fun = ggstrat_samples)

Arguments

df

A data frame containing stratigraphic data.

plot_fun

A function that generates a stratigraphic plot. Defaults to ggstrat_samples().

Value

A Shiny app object.

Examples

if (interactive()) {
# Use your default plotting function
run_ggstrat_app(example_data_strat)

# Or swap in a custom plotting function
run_ggstrat_app(example_data_strat, plot_fun = ggstrat_column)
}

Stratigraphic fill scale

Description

A ggplot2 fill scale that uses one of the built-in stratigraphic palettes.

Usage

scale_fill_stratpal(
  palette = c("stratpal_rpg", "stratpal_grays"),
  overrides = NULL,
  allow_na = FALSE,
  na_color = "gray90",
  ...
)

Arguments

palette

Character string naming which palette to use. Options are names of palettes in .stratpalettes.

overrides

Optional named character vector of colors to override entries in the chosen palette.

allow_na

Logical. If TRUE, missing categories are filled with na_color instead of erroring.

na_color

Color to use for missing categories when allow_na = TRUE.

...

Additional arguments passed to ggplot2::scale_fill_manual().

Value

A ggplot2 scale object.

Examples

library(ggplot2)
ggplot(mtcars, aes(factor(cyl), fill = factor(cyl))) +
  geom_bar() +
  scale_fill_stratpal("stratpal_rpg")

# Override one color
scale_fill_stratpal("stratpal_rpg", overrides = c("volcanic" = "orange"))

# Allow missing categories to be filled with gray
scale_fill_stratpal("stratpal_grays", allow_na = TRUE)

Stratigraphic palettes

Description

Named character vectors of hex colors for stratigraphic plotting. These palettes can be passed to scale_fill_stratpal().

Usage

stratpal_rpg

stratpal_grays

Format

Named character vectors

An object of class character of length 30.

An object of class character of length 30.

Examples

stratpal_rpg["volcanic"]
stratpal_grays["soil"]


Custom theme for stratigraphic plots

Description

A ggplot2 theme designed to work well with typical plot ouput from avstrat, and matching the author's preferred aesthetics.

Usage

theme_avstrat(base_size = 11, base_family = "arial")

Arguments

base_size

Base font size. Defaults to 11.

base_family

Base font famil. Defaults to Arial.

Value

A ggplot2::theme() object.

Examples

# Apply a custom theme to one plot
ggstrat(df = example_data_strat, section_name = "21LSHD02") +
  theme_avstrat()

# Set the custom theme as default for all plots
ggplot2::theme_set(theme_avstrat())
ggstrat(df = example_data_strat, section_name = "21LSHD02")

Validate a stratigraphic palette

Description

Ensures that a palette covers all required categories. By default, missing categories trigger an error. If allow_na = TRUE, missing categories are filled with a default color instead.

Usage

validate_stratpal(pal, allow_na = FALSE, na_color = "gray90")

Arguments

pal

Named character vector of colors.

allow_na

Logical. If TRUE, missing categories are filled with na_color instead of erroring.

na_color

Color to use for missing categories when allow_na = TRUE.

Value

A complete palette (named character vector) ordered to match the required categories.

Examples

# A complete palette passes validation
validate_stratpal(stratpal_rpg)

# Allow missing categories to be filled with gray
validate_stratpal(stratpal_grays, allow_na = TRUE)

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.