Package 'rgeomorphon'

Title: A Lightweight Implementation of the Geomorphon Algorithm
Description: A lightweight implementation of the geomorphon terrain form classification algorithm of Jasiewicz and Stepinski (2013) <doi:10.1016/j.geomorph.2012.11.005> based largely on the 'GRASS GIS' 'r.geomorphon' module. This implementation employs a novel algorithm written in C++ and 'RcppParallel'.
Authors: Andrew Brown [aut, cre] (ORCID: <https://orcid.org/0000-0002-4565-533X>)
Maintainer: Andrew Brown <[email protected]>
License: GPL (>= 3)
Version: 0.4.0
Built: 2026-11-26 19:10:27 UTC
Source: https://github.com/brownag/rgeomorphon

Help Index


Create a forms_matrix object

Description

This constructor function wraps a 9x9 integer matrix and associates it with a set of levels, creating a 'forms_matrix' object.

Usage

forms_matrix(x, levels = get_forms_grass_enum())

Arguments

x

Integer. A 9x9 matrix.

levels

Named integer vector. Map of integer values to their string names. Default: get_forms_grass_enum()

Details

This function is intended for custom classification matrix based on positive and negative overlooks. See forms_matrix_get() for a convenient accessor for the standard classification systems with 4, 5, 6 or 10 forms.

Value

An object of class c("forms_matrix", "matrix", "array").

Examples

library(terra)
library(rgeomorphon)

# default values
x <- forms_matrix_get(num_forms = 10, levels = get_forms_grass_enum())

# inspect
x

# create a 9-class system where PEAK is combined with RIDGE
x[x == 2] <- 3
a <- get_forms_grass_enum()
a <- a[!names(a) == "G_PK"]

# create a forms matrix with custom levels
fm <- forms_matrix(x, a)

# run geomorphon algorithm
SEARCH = 7       # outer search radius (cells)
SKIP = 1         # inner skip radius (cells)
DIST = 0         # flatness distance (cells)
FLAT = 1         # flat angle threshold
MODE = "anglev1" # comparison mode

## classic volcano elevation data
data("volcano", package = "datasets")

# construct and georeference a SpatRaster object
dem <- terra::flip(terra::rast(volcano))
terra::crs(dem) <- terra::crs("EPSG:27200")
terra::ext(dem) <- c(2667400, 2668010, 6478700, 6479570)
names(dem) <- "Elevation (meters)"

# include original forms, positive, and negative output
res <- geomorphons(
    dem,
    search = SEARCH,
    skip = SKIP,
    dist = DIST,
    flat = FLAT,
    comparison_mode = MODE,
    forms = TRUE,
    positive = TRUE,
    negative = TRUE
)

 # apply custom classification to positive and negative
 res2 <- geomorphon_theme(
   forms_matrix_apply(
       x = res[[c("positive", "negative")]],
       rcl = fm
   )
 )

 # compare with default
 terra::plot(terra::rast(c(`10 form`=res$forms, `9 form`=res2)))

Apply a forms_matrix to Positive and Negative Overlooks

Description

This function applies a forms_matrix to reclassify a SpatRaster object with 2 layers containing positive and negative overlooks.

Usage

forms_matrix_apply(
  x,
  rcl = forms_matrix_get(),
  positive = "positive",
  negative = "negative",
  ...
)

Arguments

x

SpatRaster containing two layers with names specified in positive and negative.

rcl

forms_matrix. Matrix to use for classification of x. Rows are "negative" and columns are "positive".

positive

Character. Layer name of positive count. Default: "positive".

negative

Character. Layer name of negative count. Default: "negative".

...

Additional arguments passed to terra::classify().

Value

A SpatRaster containing the classification result.

See Also

forms_matrix()

Examples

library(terra)
library(rgeomorphon)

SEARCH = 7       # outer search radius (cells)
SKIP = 1         # inner skip radius (cells)
DIST = 0         # flatness distance (cells)
FLAT = 1         # flat angle threshold
MODE = "anglev1" # comparison mode

## classic volcano elevation data
data("volcano", package = "datasets")

# construct and georeference a SpatRaster object
dem <- terra::flip(terra::rast(volcano))
terra::crs(dem) <- terra::crs("EPSG:27200")
terra::ext(dem) <- c(2667400, 2668010, 6478700, 6479570)
names(dem) <- "Elevation (meters)"

res <- geomorphons(
    dem,
    search = SEARCH,
    skip = SKIP,
    dist = DIST,
    flat = FLAT,
    comparison_mode = MODE,
    forms = TRUE,
    ternary = TRUE,
    positive = TRUE,
    negative = TRUE
)

res2 <- terra::rast(lapply(c(4, 5, 6), function(n) {
  geomorphon_theme(
    forms_matrix_apply(
        x = res[[c("positive", "negative")]],
        rcl = forms_matrix_get(n)
    )
  )
}))
names(res2) <- c("forms4", "forms5", "forms6")

terra::plot(c(res, res2))

Get a forms_matrix for Geomorphon Classification

Description

Gets one of the internally defined forms matrices. A form matrix is defined for the classic 10-form output (default; Jasiewicz & Stepinski, 2013) as well as three simplified classes: 4-form, 5-form, and 6-form (Masetti et al., 2018)

Usage

forms_matrix_get(num_forms = 10, levels = get_forms_grass_enum())

Arguments

num_forms

Integer. The number of forms to classify, one of 4, 5, 6, or 10 (default).

levels

Named integer with values between 0 and 10 corresponding to form class labels. Default: get_forms_grass_enum()

Details

For creating custom classification systems see the forms_matrix() constructor.

Value

An object of class forms_matrix

References

Stepinski, T., Jasiewicz, J., 2011, Geomorphons - a new approach to classification of landform, in : Eds: Hengl, T., Evans, I.S., Wilson, J.P., and Gould, M., Proceedings of Geomorphometry 2011, Redlands, 109-112. Available online: https://www.geomorphometry.org/uploads/pdf/pdf2011/StepinskiJasiewicz2011geomorphometry.pdf

Jasiewicz, J., Stepinski, T., 2013, Geomorphons - a pattern recognition approach to classification and mapping of landforms, Geomorphology, vol. 182, 147-156. (doi:10.1016/j.geomorph.2012.11.005)

Masetti, G., Mayer, L. A., & Ward, L. G. 2018, A Bathymetry- and Reflectivity-Based Approach for Seafloor Segmentation. Geosciences, 8(1), 14. (doi:10.3390/geosciences8010014)

See Also

forms_matrix()

Examples

forms_matrix_get()

Calibration of Geomorphon Parameters Against Reference Targets

Description

Evaluates spatial concordance between multiple runs of a geomorphon_sweep() and reference categorical target raster layers. Combines sweep parameter metadata with concordance metrics, boundary-density penalties, and Pareto-optimal frontier identification.

Usage

geomorphon_calibrate(
  sweep_obj,
  targets,
  forms = NULL,
  method = c("both", "nmi", "boundary"),
  threshold_cells = 2,
  spatial_null = TRUE
)

Arguments

sweep_obj

An object of class geomorphon_sweep.

targets

A single- or multi-layer categorical SpatRaster representing reference classification targets (e.g. from geomorphon_targets()).

forms

Character vector of form taxonomies to evaluate (e.g. c("forms10", "forms6")). Default is NULL, which evaluates all taxonomies found in sweep_obj.

method

Character concordance method: "both" (default), "nmi", or "boundary". Passed to geomorphon_concordance().

threshold_cells

Integer or numeric cell distance tolerance for boundary metrics. Default is 2.

spatial_null

Logical. Whether to evaluate spatial-null circular shift ensembles in geomorphon_concordance(). Default is TRUE.

Value

A tidy data.frame combining sweep parameter columns (run_id, search, skip, flat_angle_deg, dist, comparison_mode, tdist, resolution, elapsed_sec, n_cells), forms, target, concordance metrics, edge_ratio, density_penalty, is_pareto, and pareto_score.

Examples

library(terra)
data(salton, package = "rgeomorphon")
dem <- rast(salton)
crs(dem) <- attr(salton, "crs")
ext(dem) <- attr(salton, "extent")
sw <- geomorphon_sweep(dem, param_grid = list(search = c(3, 4)), forms = "forms6")
cat_rast <- (dem > 50) + 1
levels(cat_rast) <- data.frame(id = 1:2, category = c("Low", "High"))
names(cat_rast) <- "elevation_class"
cal <- geomorphon_calibrate(sw, targets = cat_rast, spatial_null = FALSE)
print(cal)

Apply Geomorphon Theme to Result Object

Description

Applies standard class names and colors to a SpatRaster, or creates a factor matrix. Input values should be integers between 1 and 10.

Usage

geomorphon_categories()

geomorphon_colors()

geomorphon_theme(x, forms = "forms10")

Arguments

x

A SpatRaster or matrix object.

forms

character. One of: "forms10" (default), "forms6", "forms5", "forms4". These are themes corresponding to the built-in 10-form, 6-form, 5-form, and 4-form ⁠"forms⁠" outputs from geomorphons().

Details

When x is a matrix the result is a factor using geomorphon_categories(). Values are integers 1 to 10 and labels are the geomorphon form names.

Value

A SpatRaster or matrix object with geomorphon class names (and colors for SpatRaster) applied.

Examples

geomorphon_theme(1:10)

Estimate Tile Processing Needs

Description

geomorphon_chunks_needed() is a heuristic for number of tiles needed to calculate geomorphons on larger-than-memory rasters. Allows for scaling by number of parallel workers, a multiplicative factor for the memory needs, and a multiplicative factor for worker needs.

Usage

geomorphon_chunks_needed(
  x,
  workers = Sys.getenv("R_RGEOMORPHON_N_WORKERS", unset = 1),
  scl_need = Sys.getenv("R_RGEOMORPHON_MEM_SCALE_NEED", unset = 10),
  scl_workers = Sys.getenv("R_RGEOMORPHON_MEM_SCALE_WORKERS", unset = 1),
  pow_total = Sys.getenv("R_RGEOMORPHON_MEM_POWER", unset = 0.5)
)

Arguments

x

A SpatRaster object.

workers

integer. Number of parallel workers. Default uses value of environment variable R_RGEOMORPHON_N_WORKERS. If unset, 1

scl_need

numeric. Scaling factor for memory needs. Default uses value of environment variable R_RGEOMORPHON_MEM_SCALE_NEED. If unset, 10.

scl_workers

numeric. Scaling factor for each worker. Default uses value of environment variable R_RGEOMORPHON_MEM_SCALE_WORKERS. If unset, 1.

pow_total

numeric. Exponent for scaling total number of chunks. Default uses value of environment variable R_RGEOMORPHON_MEM_POWER. If unset, 1.

Value

integer. Number of tile chunks to divide x into.

Examples

data("salton", package = "rgeomorphon")

x <- terra::rast(salton)
terra::ext(x) <- attr(salton, "extent")
terra::crs(x) <- attr(salton, "crs")

geomorphon_chunks_needed(x)

Calculate Structural Concordance Between Geomorphon and Categorical Maps

Description

Measures the degree of structural agreement between a geomorphon classification and another categorical map (e.g., soil types, vegetation classes) using Normalized Mutual Information and boundary alignment metrics.

Usage

geomorphon_concordance(
  geo_rast,
  cat_rast,
  method = c("both", "nmi", "boundary"),
  threshold_cells = 2,
  spatial_null = TRUE
)

Arguments

geo_rast

SpatRaster. Geomorphon classification raster (typically output from geomorphons()).

cat_rast

SpatRaster. Categorical comparison raster (e.g., soil map, vegetation map). Must have matching extent and resolution to geo_rast.

method

Character. Which concordance metrics to calculate. One of "nmi" (Normalized Mutual Information only), "boundary" (boundary alignment only), or "both" (all metrics). Default: "both".

threshold_cells

Integer. Buffer distance in cells for boundary concordance calculation, converted to map units with the cell size. Categorical boundary cells within this distance of the nearest geomorphon boundary cell are counted as concordant. Must be a finite, non-negative whole number when method includes boundary metrics. Geographic (longitude/latitude) CRS inputs are rejected with an error when method includes boundary metrics because boundary distances require a planar Cartesian CRS. Default: 2.

spatial_null

Logical. Whether to calculate the spatial-null ensemble. If FALSE, skip it and return NA_real_ null means/deltas and zero shift counts. Default: TRUE.

Value

A list with the following components (depending on method):

nmi

Numeric. Normalized Mutual Information (0-1). Higher values indicate stronger statistical association between classifications. Existing NMI behavior is unchanged. Only included when method includes "nmi".

homogeneity

Numeric. ⁠I(geo; cat) / H(cat)⁠, measuring how well the geomorphon classes determine the categorical reference. NA_real_ when H(cat) = 0; otherwise zero for a constant geomorphon map against a varying categorical map. Included only for methods "nmi" and "both".

completeness

Numeric. ⁠I(geo; cat) / H(geo)⁠, measuring how completely the categorical classes capture geomorphon information. NA_real_ when H(geo) = 0; otherwise zero for a constant categorical map against a varying geomorphon map. Included only for methods "nmi" and "both".

edge_offset

Numeric. Mean distance (in map units) from each categorical boundary cell to the nearest geomorphon boundary cell. Lower values indicate better boundary alignment. Only included when method includes "boundary".

edge_concordance

Numeric. Proportion (0-1) of categorical boundary cells within threshold_cells of the nearest geomorphon boundary cell. Higher values indicate better alignment. Only included when method includes "boundary".

edge_f1

Numeric. Symmetric threshold-based boundary F1 (0-1). NA_real_ if either shared-domain boundary set is empty. Included when method includes "boundary".

edge_mhd

Numeric. Maximum of the two directed mean nearest-boundary distances, in map units; not classical maximum Hausdorff distance. NA_real_ if either shared-domain boundary set is empty. Included when method includes "boundary".

edge_chamfer

Numeric. Mean of the two directed mean nearest-boundary distances, in map units. NA_real_ if either shared-domain boundary set is empty. Included when method includes "boundary".

n_cells

Integer. Total number of valid cells analyzed.

n_edges_geo

Integer. Number of geomorphon boundary cells. Only included when method includes "boundary".

n_edges_cat

Integer. Number of categorical boundary cells. Only included when method includes "boundary".

contingency_table

Matrix. Cross-tabulation of geomorphon vs. categorical classes. Only included when method includes "nmi".

class_homogeneity

Numeric vector. Per-geomorphon-class homogeneity scores ⁠1 - H(cat | geo = g) / H(cat)⁠, named by geomorphon class. Row-weighted mean equals homogeneity. Included only for methods "nmi" and "both".

class_completeness

Numeric vector. Per-category-class completeness scores ⁠1 - H(geo | cat = c) / H(geo)⁠, named by category class. Column-weighted mean equals completeness. Included only for methods "nmi" and "both".

mean_null_nmi

Numeric. Arithmetic mean NMI across eligible deterministic spatial translations. NA_real_ if no shifts have paired-valid cells. Included only for methods "nmi" and "both".

delta_nmi

Numeric. Observed nmi minus mean_null_nmi; may be negative and is NA_real_ if either score is NA. Included only for methods "nmi" and "both".

nmi_null_shifts

Integer. Number of evaluated shifts eligible for the NMI null mean (shifts with paired-valid cells). Included only for methods "nmi" and "both".

mean_null_edge_f1

Numeric. Arithmetic mean edge F1 across shifts with nonempty edge sets. NA_real_ if no shifts are eligible. Included only for methods "boundary" and "both".

delta_edge_f1

Numeric. Observed edge_f1 minus mean_null_edge_f1; may be negative and is NA_real_ if either score is NA. Included only for methods "boundary" and "both".

edge_f1_null_shifts

Integer. Number of evaluated shifts eligible for the edge-F1 null mean (both edge sets nonempty). Included only for methods "boundary" and "both".

null_shifts_evaluated

Integer. Number of non-identity shifts evaluated for the null ensemble, shared by the requested metrics.

Information-Theoretic Concordance

Normalized Mutual Information (NMI) measures the mutual dependence between two categorical variables, independent of the specific class mappings. An NMI of 1 indicates perfect association, while 0 indicates independence. When NMI is requested, the result also includes directional homogeneity and completeness. With cat_rast as the reference, ⁠homogeneity = I(geo; cat) / H(cat)⁠ and ⁠completeness = I(geo; cat) / H(geo)⁠. Swapping the rasters swaps these two values but leaves NMI unchanged. When both entropies are positive, their harmonic mean equals NMI. A component with a zero entropy denominator is NA_real_; the other component is zero when defined. If both maps are constant, both components are NA_real_ while existing NMI remains 0. These additive components do not change the existing NMI calculation or values.

Boundary Alignment

Boundary alignment measures physical proximity between geomorphon and categorical boundaries. The edge_offset is the mean distance from each categorical boundary cell to the nearest geomorphon boundary cell, in map units of the input CRS. The edge_concordance is the proportion of categorical boundary cells within a threshold distance of the nearest geomorphon boundary cell. These legacy summaries retain their directional definitions and per-input valid masks.

The additive edge_f1, edge_mhd, and edge_chamfer summaries are symmetric. They detect boundaries for both maps only within their shared non-NA cells. edge_f1 is threshold-based: precision and recall are the proportions of boundary cells in each map within the threshold of a boundary in the other map, and F1 is their harmonic mean (range 0-1). It is not a kernel F1 or a one-to-one matched-boundary score. edge_mhd is the maximum of the two directed mean nearest-boundary distances; despite its name, it is not the classical maximum Hausdorff distance. edge_chamfer is the mean of those directed means. The distance summaries are non-negative and use input CRS map units. Each new score is NA_real_ if either shared-domain boundary set is empty.

Shared-domain edges use the existing eight-neighbor rule and exclude raster borders. Mask holes are not boundaries and do not block nearest-boundary distances. threshold_cells is multiplied by the x-resolution, including for rectangular cells; distance calculations use both cell dimensions. When input NA masks differ, legacy counts and directional summaries still use their existing per-input masks, so they need not describe the edges used by the new shared-domain scores.

For rasters to be comparable, they must have matching row and column counts, extents, and resolutions. Use terra::crop(), terra::resample(), or terra::disagg() to align rasters before calling this function.

The NMI is symmetric and normalized to the range 0-1, with higher values indicating stronger association regardless of how classes map to each other. Homogeneity and completeness are directional: cat_rast is the reference for their definitions, so swapping inputs exchanges the scores. If both marginal entropies are positive, their harmonic mean equals NMI. A zero denominator yields NA_real_ for that component; for two constant maps both components are NA_real_ and NMI remains 0. These fields are returned only by method = "nmi" or "both", not by "boundary". The boundary metrics are useful for validating whether geomorphological transitions correspond to ecological or pedological boundaries.

The additive spatial-null summaries compare the observed alignment with a deterministic sample of up to 128 non-identity circular translations of cat_rast; all candidate shifts are used when fewer than 128 exist. The schedule is defined for a raster with nr rows and nc columns by M = nr * nc - 1, S = min(128, M), and k_i = floor((i + 0.5) * M / S) for ⁠i = 0, ..., S - 1⁠. For each index, q = k_i + 1 and the row/column shift is ⁠(dr, dc) = (q %/% nc, q %% nc)⁠. Using zero-based coordinates, the source category at destination ⁠(r, c)⁠ is ⁠[(r - dr) mod nr, (c - dc) mod nc]⁠; the geomorphon map stays fixed. Outputs contain aggregate summaries only, not per-shift scores. The category values and their NA mask move together, and paired-valid cells are recomputed for each shift. NMI uses base-2 entropy and is zero when both marginal entropies are zero. Null edge F1 uses shared-valid eight-neighbor edges (excluding image borders) and toroidal Euclidean distances in cell coordinates with threshold_cells; a shift with either edge set empty is ineligible for its mean. Null summaries are arithmetic means over eligible shifts; deltas are observed minus mean and are not clamped. With no eligible shifts, the corresponding summary and delta are NA_real_ and its eligible count is zero. These are descriptive contrasts against this translation ensemble, not adjusted mutual information, calibrated scores, p-values, or evidence of statistical significance. NMI-null fields are returned only for method = "nmi" or "both"; edge-F1-null fields only for method = "boundary" or "both". null_shifts_evaluated is always returned. When spatial_null = FALSE, the ensemble is skipped, null means and deltas are NA_real_, and shift counts are 0L.

Note

Memory Requirements: This function performs edge detection on both input rasters. For small to medium rasters (< 1GB each), a fast C++ implementation is used. For larger rasters, the function automatically falls back to terra::boundaries() which is slower but more memory-efficient.

Since both rasters are processed simultaneously, the total memory requirement can approach 4x the size of a single raster in the worst case. For rasters larger than available RAM:

  • Process in tiles using terra::makeTiles()

  • Increase available system memory

  • Consider splitting the analysis into smaller regions

See Also

geomorphons(), terra::boundaries()

Examples

library(terra)
library(rgeomorphon)

# Load example DEM
data("volcano", package = "datasets")
dem <- rast(volcano)
crs(dem) <- crs("EPSG:2193")
ext(dem) <- c(1756968, 1757578, 5917000, 5917870)

# Calculate geomorphons
geo <- geomorphons(dem, search = 7, simplify = TRUE)

# Create synthetic categorical map for demonstration
cat_map <- dem
values(cat_map) <- cut(values(dem), breaks = 5, labels = FALSE)

# Calculate concordance
conc <- geomorphon_concordance(geo, cat_map)
print(conc$nmi)
print(conc$edge_concordance)
print(conc[c("edge_f1", "edge_mhd", "edge_chamfer")])

Cell-Wise Divergence Between Landform Proportion Ensembles

Description

Computes cell-wise divergence and summary statistics between two aligned multi-layer class-proportion ensembles (e.g. from geomorphon_ensemble() with method = "proportions"), or two lists of proportion matrices / numeric matrices.

Usage

geomorphon_divergence(p, q, method = "jensen-shannon", unit = "log2")

Arguments

p

A multi-layer class-proportion SpatRaster or numeric matrix / matrix list.

q

A multi-layer class-proportion SpatRaster or numeric matrix / matrix list aligned with p.

method

Character distance metric. Default is "jensen-shannon".

unit

Logarithm unit. Default is "log2".

Value

A list containing:

raster

A single-layer SpatRaster named "divergence", returned for raster input.

matrix

The cell-vector divergence as a numeric matrix, returned for matrix or list input.

mean_divergence

Arithmetic mean divergence across valid cells.

median_divergence

Median divergence across valid cells.

q90_divergence

90th percentile divergence across valid cells.

n_cells

Count of valid cells compared.

Examples

library(terra)
p <- rast(array(c(0.8, 0.2, 0.5, 0.5), dim = c(2, 2, 2)))
q <- rast(array(c(0.2, 0.8, 0.5, 0.5), dim = c(2, 2, 2)))
names(p) <- names(q) <- c("Flat", "Slope")
div <- geomorphon_divergence(p, q)
div$mean_divergence

Ensemble Aggregation of Geomorphon Classifications

Description

Computes cell-wise ensemble summaries across parameter sweep runs, supporting deterministic modal classification and per-class proportion layers.

Usage

geomorphon_ensemble(
  sweep_obj,
  method = c("modal", "proportions"),
  form = NULL,
  classes = NULL,
  ties = "lowest",
  ...
)

Arguments

sweep_obj

An object of class geomorphon_sweep, a list of SpatRaster objects, or a multi-layer SpatRaster representing runs of a parameter sweep.

method

character. Aggregation method: "modal" (default) computes the modal landform class per cell; "proportions" computes per-class proportions across non-NA runs.

form

character or numeric. Which form taxonomy to aggregate when multiple exist in sweep_obj (e.g. "forms10", "forms6", "forms5", "forms4"). Defaults to the first or only form available.

classes

integer or character vector. Which landform classes to compute proportions for when method = "proportions". Defaults to NULL, which evaluates all reachable classes for form (10 for forms10, 6 for forms6, 5 for forms5, 4 for forms4), matching geomorphon_categories().

ties

character. Tie-breaking rule for method = "modal". Passed to terra::modal(), default is "lowest" for deterministic tie-breaking.

...

Additional arguments passed to methods.

Value

A SpatRaster (or matrix / list of matrices) containing the aggregated ensemble. For method = "modal", returns a single layer with geomorphon factor levels and color table applied. For method = "proportions", returns multi-layer proportions named by class.

Examples

## Not run: 
library(terra)
data("salton", package = "rgeomorphon")
dem <- rast(salton)
crs(dem) <- attr(salton, "crs")
ext(dem) <- attr(salton, "extent")

grid <- data.frame(search = c(3, 5), skip = c(0, 1))
sw <- geomorphon_sweep(dem, param_grid = grid, forms = "forms10")

ens_mode <- geomorphon_ensemble(sw, method = "modal")
ens_prop <- geomorphon_ensemble(sw, method = "proportions")

## End(Not run)

Multi-Objective Pareto Frontier and Composite Calibration Score

Description

Identifies non-dominated Pareto-optimal parameter sets and computes composite harmonic-mean scores over multi-objective evaluation tables.

Usage

geomorphon_pareto(
  cal_df,
  objectives = NULL,
  by = "target",
  min_edge_ratio = 0,
  max_edge_ratio = Inf
)

Arguments

cal_df

A data.frame containing calibration evaluation metrics (such as the output of geomorphon_calibrate()).

objectives

Named character vector defining optimization directions for each objective (e.g. c(delta_nmi = "max", delta_edge_f1 = "max", edge_mhd = "min")). Values must be "max" or "min". If NULL, default objectives are selected based on available columns.

by

Character vector of column names defining independent Pareto grouping domains. Default is "target".

min_edge_ratio

Minimum permissible edge_ratio (n_edges_geo / n_edges_cat). Default is 0.

max_edge_ratio

Maximum permissible edge_ratio. Default is Inf.

Value

The input cal_df augmented with:

is_pareto

Logical. TRUE if the candidate belongs to the non-dominated Pareto frontier within its group.

pareto_score

Numeric in [0,1][0, 1]. Normalized composite score computed as the harmonic mean across normalized objectives.

Examples

df <- data.frame(
  target = "musym",
  run_id = 1:3,
  edge_ratio = c(1.1, 1.2, 0.9),
  delta_nmi = c(0.12, 0.15, 0.10),
  delta_edge_f1 = c(0.20, 0.18, 0.22),
  edge_mhd = c(45, 40, 50)
)
geomorphon_pareto(df)

Pairwise Dissimilarity of Concordance Profiles

Description

Computes the pairwise dissimilarity matrix between conditional probability profiles from a contingency table or geomorphon_concordance() output using exact base-2 Jensen-Shannon divergence (default) or any method supported by philentropy.

Usage

geomorphon_profile_dist(
  x,
  margin = 1,
  method = "jensen-shannon",
  unit = "log2"
)

Arguments

x

A geomorphon_concordance result list (containing contingency_table) or a 2D contingency table or numeric matrix.

margin

Integer indicating the profile direction: 1 for row profiles (e.g. P(Category∣Geomorphon)P(\text{Category} \mid \text{Geomorphon})), or 2 for column profiles (e.g. P(Geomorphon∣Category)P(\text{Geomorphon} \mid \text{Category})). Default is 1.

method

Character string specifying distance metric. Default is "jensen-shannon".

unit

Logarithm unit ("log2", "log", "log10"). Default is "log2".

Value

A symmetric numeric distance matrix with row and column names matching the profile labels.

Examples

ct <- matrix(c(10, 0, 5, 5, 0, 10), nrow = 3, byrow = TRUE)
rownames(ct) <- c("Flat", "Slope", "Ridge")
colnames(ct) <- c("CatA", "CatB")
geomorphon_profile_dist(ct, margin = 1)

Calculate Perceived Terrain Realism Metric (PTRM)

Description

Calculates the Perceived Terrain Realism Metric based on the distribution of geomorphon landform features. The PTRM provides a quantitative estimate of human-perceived terrain realism by relating the proportions of terrain features to their perceived realism.

Usage

geomorphon_ptrm(
  x,
  mode = c("dem", "class"),
  search = 3,
  skip = 0,
  flat_angle_deg = 1,
  dist = 0,
  forms = "forms10",
  coefficients = NULL,
  intercept = -38.02,
  normalizer = 69.96,
  ...
)

Arguments

x

SpatRaster. Either a Digital Elevation Model (when mode = "dem") or a geomorphon classification raster (when mode = "class").

mode

Character. One of "dem" or "class". When "dem", geomorphons are calculated from the input DEM. When "class", the input is assumed to be a pre-computed geomorphon classification. Default: "dem".

search

Numeric. Search radius for geomorphon calculation (only used when mode = "dem"). Units depend on the CRS of the input. Default: 3. This is a convenience default, not a value calibrated against the PTRM paper, so it should not be read as a validated choice.

skip

Numeric. Skip radius for geomorphon calculation (only used when mode = "dem"). Default: 0.

flat_angle_deg

Numeric. Flatness angle threshold in degrees (only used when mode = "dem"). Default: 1.0.

dist

Numeric. Flatness distance (only used when mode = "dem"). Default: 0.

forms

Character. Form system to use: "forms10", "forms6", "forms5", or "forms4". Default: "forms10".

coefficients

Named numeric vector. Custom PTRM coefficients for each geomorphon class. If NULL, uses default values from Rajasekaran et al. (2022). Names should match geomorphon form names. A ten-form vector is reduced to the requested forms system. Default: NULL.

intercept

Numeric. PTRM intercept. Default: -38.02.

normalizer

Numeric. PTRM divisor. Must be finite and non-zero. Default: 69.96.

...

Additional arguments passed to geomorphons() when mode = "dem". Ignored when mode = "class".

Value

A list containing:

ptrm_score

Numeric. PTRM value obtained by dividing the raw score by the normalizer. Scores are raw and may fall outside ⁠[0, 1]⁠; higher values indicate more realistic terrain.

raw_score

Numeric. Unnormalized score before division.

proportions

Named numeric vector. Proportion of each observed geomorphon form in the input, named with the canonical system labels.

n_cells

Integer. Total number of valid (non-NA) cells analyzed.

Distance Calculation and Coordinate Reference Systems

The geomorphon classification algorithm assumes planar distances, so it is strongly recommended that elevation data be in a projected coordinate system.

Tiled Processing

When mode = "dem", geomorphons are calculated internally. For large DEMs, this may trigger the automatic tiled processing workflow. See geomorphons() for details.

The PTRM is calculated using the formula:

PTRM=c0+∑i=1nci×piDPTRM = \frac{c_0 + \sum_{i=1}^{n} c_i \times p_i}{D}

where c0c_0 is the intercept (-38.02 by default), cic_i are the coefficients for each geomorphon form, pip_i are the proportions of each form in the terrain, and DD is the divisor (69.96 by default). The intercept, normalizer, and coefficients can all be overridden.

The returned score is not clamped or rescaled, so it may fall outside ⁠[0, 1]⁠ depending on the input distribution and the model parameters. Higher PTRM scores indicate more realistic terrain from a human perception perspective. Rajasekaran et al. (2022) found that real terrain from Arizona achieved a PTRM of 0.76, ranking in the 78th percentile for perceived realism.

References

Rajasekaran, S.D., Kang, H., Čadík, M., Galin, E., Guérin, E., Peytavie, A., Slavík, P., & Mech, R. (2022). PTRM: Perceived Terrain Realism Metric. ACM Transactions on Applied Perception, 19(2), Article 5. doi:10.1145/3514244

Jasiewicz, J., Stepinski, T. (2013). Geomorphons - a pattern recognition approach to classification and mapping of landforms. Geomorphology, 182, 147-156. doi:10.1016/j.geomorph.2012.11.005

See Also

geomorphons(), geomorphon_categories()

Examples

library(terra)
library(rgeomorphon)

# Load example DEM
data("volcano", package = "datasets")
dem <- rast(volcano)
crs(dem) <- crs("EPSG:2193")
ext(dem) <- c(1756968, 1757578, 5917000, 5917870)

# Calculate PTRM from DEM
ptrm1 <- geomorphon_ptrm(dem, mode = "dem", search = 7)
print(ptrm1$ptrm_score)

# Or calculate geomorphons first, then PTRM
geo <- geomorphons(dem, search = 7, simplify = TRUE)
ptrm2 <- geomorphon_ptrm(geo, mode = "class")

# Results should be identical
all.equal(ptrm1$ptrm_score, ptrm2$ptrm_score)

Calculate Focal (Moving Window) PTRM

Description

Calculates Perceived Terrain Realism Metric (PTRM) for each pixel using a circular moving window. Produces a spatially-varying measure of local terrain complexity and realism.

Usage

geomorphon_ptrm_focal(
  x,
  radius = 3,
  mode = c("dem", "class"),
  coefficients = NULL,
  forms = "forms10",
  intercept = -38.02,
  normalizer = 69.96,
  search = 3,
  skip = 0,
  flat_angle_deg = 1,
  dist = 0,
  filename = NULL,
  overwrite = FALSE,
  ...
)

Arguments

x

SpatRaster. Digital Elevation Model (when mode = "dem") or pre-computed geomorphon classification (when mode = "class").

radius

Numeric. Integer window radius in cells (not map units). Default: 3. Larger values compute PTRM from larger neighborhoods.

mode

Character. Input type: "dem" to calculate geomorphons internally, or "class" if input is pre-computed geomorphon classification. Default: "dem".

coefficients

Named numeric vector. Custom PTRM coefficients, either named for the requested form system (length k) or a named ten-form vector, which is reduced to the requested system. If NULL, uses the paper weights from Rajasekaran et al. (2022), derived for reduced form systems. Default: NULL.

forms

Character. Form system to use: "forms10", "forms6", "forms5", or "forms4". Default: "forms10".

intercept

Numeric. PTRM intercept. Default: -38.02.

normalizer

Numeric. PTRM normalizer; must be finite and non-zero. Default: 69.96.

search

Numeric. Search radius for geomorphon calculation (only used when mode = "dem"). Default: 3.

skip

Numeric. Skip radius for geomorphon calculation (only used when mode = "dem"). Default: 0.

flat_angle_deg

Numeric. Flatness angle threshold in degrees (only used when mode = "dem"). Default: 1.0.

dist

Numeric. Flatness distance parameter (only used when mode = "dem"). Default: 0.

filename

Character. Output filename. If provided, the result is written to disk instead of returned in memory. Default: NULL.

overwrite

Logical. Overwrite existing file? Default: FALSE.

...

Additional arguments passed to geomorphons() when mode = "dem".

Details

The PTRM score measures local terrain realism on a continuous scale. Higher values indicate more realistic terrain patterns according to the perception model of Rajasekaran et al. (2022). The focal version applies this metric locally to map spatial variation in terrain complexity.

Computational Complexity:

  • Geomorphons: O(N × 8R) where R = search radius

  • Focal PTRM: O(N × W) where W ≈ π × radius²

  • Total: O(N × (8R + W))

For a 1000×1000 DEM with radius=5, search=7:

  • Expected runtime: 3-6 seconds on modern multi-core system

  • Memory: ~20 MB

Value

A SpatRaster with raw focal PTRM scores. Values are not normalized to ⁠[0, 1]⁠ and may fall outside that range. Border cells are NA.

Algorithm

Uses a two-pass approach for efficiency:

  1. Calculate geomorphons globally (if mode = "dem")

    • Applies the full geomorphon classification algorithm once

    • Produces classification raster with classes 1-10

  2. Apply focal PTRM calculation to each pixel's neighborhood

    • For each interior pixel, extracts geomorphon classes within circular window

    • Calculates proportions of each geomorphon form

    • Applies PTRM formula using empirical coefficients

    • Returns spatially-varying PTRM scores

This two-pass approach is much more efficient than recalculating geomorphons for each window (~38x speedup for typical parameters).

Window Type

Uses a circular window based on Euclidean distance. For an integer radius = r, includes all cells where sqrt(dx^2 + dy^2) <= r.

Border Handling

Cells within radius distance of raster edges are set to NA, as their neighborhoods are incomplete. This prevents edge artifacts in the output.

Memory Requirements

For small/medium rasters, uses the fast C++ implementation requiring approximately 4 bytes per input cell plus 8 bytes per output cell (about 12 bytes per cell) in RAM. For large rasters that exceed half of the available memory, automatically falls back to block-processed terra::focal(), which is slower but avoids full-raster R matrices. Without filename, terra-backed temporary storage is used for intermediate results.

References

Rajasekaran, S.D., Kang, H., Čadík, M., Galin, E., Guérin, E., Peytavie, A., Slavík, P., & Mech, R. (2022). PTRM: Perceived Terrain Realism Metric. ACM Transactions on Applied Perception, 19(2), Article 5. doi:10.1145/3514244

Jasiewicz, J., Stepinski, T. (2013). Geomorphons - a pattern recognition approach to classification and mapping of landforms. Geomorphology, 182, 147-156. doi:10.1016/j.geomorph.2012.11.005

See Also

geomorphon_ptrm(), geomorphons(), terra::focal()

Examples

library(terra)
library(rgeomorphon)

# Load example DEM
data("volcano", package = "datasets")
dem <- rast(volcano)
crs(dem) <- crs("EPSG:2193")
ext(dem) <- c(1756968, 1757578, 5917000, 5917870)

# Calculate focal PTRM with 5-cell radius
ptrm_focal <- geomorphon_ptrm_focal(dem, radius = 5, mode = "dem")

# Compare different window sizes
ptrm_r3 <- geomorphon_ptrm_focal(dem, radius = 3)
ptrm_r7 <- geomorphon_ptrm_focal(dem, radius = 7)

Parameter Sweep for Geomorphon Terrain Classification

Description

Evaluates a grid of parameter combinations over a Digital Elevation Model (DEM), taking advantage of line-of-sight ray-tracing count reuse across multiple form taxonomies in each evaluation. Records execution runtime and parameter metadata in a tidy summary table.

Usage

geomorphon_sweep(
  elevation,
  param_grid,
  forms = c("forms10", "forms6", "forms5", "forms4"),
  ...
)

Arguments

elevation

A SpatRaster or numeric matrix containing elevation data.

param_grid

A data.frame or list containing parameter combinations. May contain columns or list elements for search, skip, flat_angle_deg (or flat), dist, comparison_mode, and tdist. If a list of vectors is supplied, it is expanded via expand.grid(). Any combinations where skip >= search are pruned with a warning.

forms

character or numeric vector. Landform taxonomies to compute for each parameter combination. Default is c("forms10", "forms6", "forms5", "forms4").

...

Additional arguments passed to geomorphons().

Value

An S3 object of class geomorphon_sweep containing:

summary

A tidy data.frame with columns run_id, parameter values, resolution, elapsed_sec (runtime in seconds), and n_cells.

rasters

A named list of classification outputs (one per run_id).

Examples

## Not run: 
library(terra)
data("salton", package = "rgeomorphon")
dem <- rast(salton)
crs(dem) <- attr(salton, "crs")
ext(dem) <- attr(salton, "extent")

grid <- list(
  search = c(3, 5),
  skip = c(0, 1),
  flat_angle_deg = 1.0
)

sw <- geomorphon_sweep(dem, param_grid = grid, forms = c("forms10", "forms6"))
print(sw)
summary(sw)

## End(Not run)

Reference Attribute Table Target Layer Generator

Description

Derives aligned categorical raster layers from an integer ID raster and its Reference Attribute Table (RAT), with support for categorical columns and binned numeric columns. Attaches coverage statistics describing valid cell proportions and class counts.

Usage

geomorphon_targets(
  x,
  attrs = NULL,
  id_col = 1,
  vars = NULL,
  breaks = list(),
  labels = list(),
  right = TRUE
)

Arguments

x

A single-layer categorical or integer SpatRaster.

attrs

Optional data.frame containing the attribute table. If NULL (default), the table is extracted from terra::cats(x)[[1]].

id_col

Column index or column name in attrs containing the keys that match raster values in x. Default is 1.

vars

Character vector of column names in attrs to convert into target raster layers. Default is all columns except id_col.

breaks

Named list of numeric break vectors for binning continuous attribute columns using base::cut().

labels

Named list of character vectors of category labels corresponding to breaks.

right

Logical. Indicating if the intervals should be closed on the right (and open on the left) or vice versa. Default is TRUE. Passed to base::cut().

Value

A multi-layer SpatRaster where each layer corresponds to a derived target variable with categories set via terra::levels(). The returned raster has an attached attribute "coverage", a tidy data.frame containing:

target

Target layer name.

n_total

Total number of cells.

n_valid

Number of valid non-NA cells.

n_na

Number of missing (NA) cells.

prop_valid

Proportion of valid cells (n_valid / n_total).

n_classes

Number of factor levels / distinct categories.

Examples

library(terra)
r <- rast(matrix(c(1, 2, 1, 3), nrow = 2, ncol = 2))
rat <- data.frame(id = 1:3, landuse = c("Forest", "Water", "Forest"), slope = c(12, 1, 25))
targets <- geomorphon_targets(r, attrs = rat, id_col = "id", vars = "landuse")
attr(targets, "coverage")

Calculate Geomorphons

Description

'Rcpp' implementation of the geomorphon terrain classification system based on 'r.geomorphon' algorithm of Jasiewicz and Stepinski (2013) from 'GRASS GIS'.

Usage

geomorphons(
  elevation,
  filename = NULL,
  search = 3,
  skip = 0,
  flat_angle_deg = 1,
  dist = 0,
  comparison_mode = "anglev1",
  tdist = 0,
  forms = TRUE,
  ternary = FALSE,
  positive = FALSE,
  negative = FALSE,
  use_meters = FALSE,
  nodata_val = NA_integer_,
  xres = NULL,
  yres = xres,
  simplify = FALSE,
  LAPPLY.FUN = lapply,
  nchunk = geomorphon_chunks_needed(elevation)
)

Arguments

elevation

matrix or SpatRaster object. Digital Elevation Model values. It is STRONGLY recommended to use a grid in a projected coordinate system.

filename

character. Output filename. Default NULL creates a temporary file.

search

numeric. User input for search radius (default: 3). Units depend on use_meters.

skip

numeric. User input for skip radius (default: 0). Units depend on use_meters.

flat_angle_deg

numeric. Flatness angle threshold in degrees. Default: 1.0.

dist

numeric. Flatness distance (default: 0). Units depend on use_meters.

comparison_mode

Character. One of "anglev1", "anglev2", "anglev2_distance". Default: "anglev1".

tdist

numeric. Terrain distance factor. When greater than 0, overrides Z tolerance from angular logic. Default: 0.0.

forms

character. Number of geomorphon forms to identify. One of ⁠"forms10⁠ (default), "forms6", "forms5", or ⁠"forms4⁠.

ternary

logical. Include "ternary" output? Default: FALSE

positive

logical. Include "positive" output? Default: FALSE

negative

logical. Include "negative" output? Default: FALSE

use_meters

Logical. Default: FALSE uses cell units. Set to TRUE to specify search, skip, and dist in units of meters.

nodata_val

numeric. NODATA value. Default: NA_integer_.

xres

numeric. X grid resolution (used only when elevation is a matrix). Default: NULL.

yres

numeric. Y grid resolution (used only when elevation is a matrix). Default: xres.

simplify

logical. If result is length 1 list, the first element is returned. Default: FALSE

LAPPLY.FUN

An lapply()-like function such as future.apply::future_lapply(). Default: lapply().

nchunk

Number of tile chunks to use. Default: geomorphon_chunks_needed(elevation).

Value

List of SpatRaster or matrix of geomorphon algorithm outputs. When more than one of forms, ternary, positive, negative are set the result is a list. For one result type, and default simplify argument, the result is the first (and only) element of the list.

Distance Calculation and Coordinate Reference Systems

The algorithm assumes planar distances and angles are calculated based on cell resolutions, so it is strongly recommended that elevation data be in a projected coordinate system.

Buffer Around Area of Interest

For reliable geomorphon classification, especially near study area boundaries, it is recommended to use a raster that includes a buffer of at least search + 1 cells around the area of interest. This implementation utilizes all available DEM data up to the specified search radius.

A buffer of search + skip + 1 cells is automatically applied when processing SpatRaster input, as this is necessary to avoid edge effects when processing large rasters in tiles. Matrix input is not altered.

Tiled Processing for Large Rasters

For Digital Elevation Models (DEMs) that are too large to fit into available memory, rgeomorphon employs an automatic tiled processing workflow. This method breaks the large raster into a grid of smaller, manageable chunks that are processed sequentially.

The premise of this approach is the use of buffered tiles. To ensure seamless results and avoid edge artifacts, a buffer of surrounding data is added to each chunk before the geomorphon calculation is performed. This provides the necessary neighborhood of cells for the algorithm to work correctly. After each tile is processed, the buffer region is removed from the result. Finally, the clean, processed tiles are mosaicked back together into a single, complete output raster that perfectly matches the extent of the original input DEM.

This entire workflow is handled internally by the main geomorphons() function, which can also leverage parallel processing to speed up the operation on multi-core systems. See the vignette on parallel processing with 'future' package.

The number of chunks needed can be controlled by setting several environment variables. These variables are read by the function at runtime.

Default Behavior

By default, the function assumes a single worker, scales the estimated memory needed by a factor of 10, and applies the square root to the total number of chunks. This can be replicated with the following settings:

Sys.setenv(R_RGEOMORPHON_N_WORKERS = 1)
Sys.setenv(R_RGEOMORPHON_MEM_SCALE_NEED = 10)
Sys.setenv(R_RGEOMORPHON_MEM_SCALE_WORKERS = 1)
Sys.setenv(R_RGEOMORPHON_MEM_POWER = 0.5)

Customized Behavior

You can customize the tiling behavior by setting the environment variables to different values. For example, to use four workers, scale memory needs by a factor of five, apply a worker scaling factor of two, and a power of 1.5 to the total, you would set the following:

Sys.setenv(R_RGEOMORPHON_N_WORKERS = 4)
Sys.setenv(R_RGEOMORPHON_MEM_SCALE_NEED = 5)
Sys.setenv(R_RGEOMORPHON_MEM_SCALE_WORKERS = 2)
Sys.setenv(R_RGEOMORPHON_MEM_POWER = 1.5)

Comparison with 'GRASS' 'r.geomorphon'

This implementation achieves very high agreement with the classification logic of 'GRASS GIS' 'r.geomorphon' when using equivalent parameters and data in a projected coordinate system.

'r.geomorphon' employs a row buffering strategy which can, for cells near the edges of a raster, result in a truncated line-of-sight compared to the full raster extent. This may lead GRASS to classify edge-region cells differently or as NODATA where this implementation may produce a more 'valid' geomorphon form given the available data.

More information about the 'r.geomorphon' module can be found in the GRASS GIS manual: https://grass.osgeo.org/grass-stable/manuals/r.geomorphon.html

References

Stepinski, T., Jasiewicz, J., 2011, Geomorphons - a new approach to classification of landform, in : Eds: Hengl, T., Evans, I.S., Wilson, J.P., and Gould, M., Proceedings of Geomorphometry 2011, Redlands, 109-112. Available online: https://www.geomorphometry.org/uploads/pdf/pdf2011/StepinskiJasiewicz2011geomorphometry.pdf

Jasiewicz, J., Stepinski, T., 2013, Geomorphons - a pattern recognition approach to classification and mapping of landforms, Geomorphology, vol. 182, 147-156. (doi:10.1016/j.geomorph.2012.11.005)

See Also

geomorphon_theme() geomorphon_chunks_needed()

Examples

library(terra)
library(rgeomorphon)

SEARCH = 7       # outer search radius (cells)
SKIP = 1         # inner skip radius (cells)
DIST = 0         # flatness distance (cells)
FLAT = 1         # flat angle threshold
MODE = "anglev1" # comparison mode

## classic volcano elevation data
data("volcano", package = "datasets")

# construct and georeference a SpatRaster object
dem <- terra::flip(terra::rast(volcano))
terra::crs(dem) <- terra::crs("EPSG:27200")
terra::ext(dem) <- c(2667400, 2668010, 6478700, 6479570)
names(dem) <- "Elevation (meters)"


system.time({
    rg <- geomorphons(
        dem,
        search = SEARCH,
        skip = SKIP,
        dist = DIST,
        flat = FLAT,
        comparison_mode = MODE
    )
})

plot(c(dem, rg))

Print method for a forms_matrix object

Description

Controls how the 'forms_matrix' object is displayed in the console.

Usage

## S3 method for class 'forms_matrix'
print(x, show_values = FALSE, ...)

Arguments

x

The forms_matrix object to print.

show_values

A logical value. If FALSE (default), prints enum names. If TRUE, prints the underlying integer values.

...

Additional arguments passed to print (not used here).

Value

Invisibly returns the original object x.

Examples

print(forms_matrix_get(num_forms = 4))

Bathymetric Information on California's Salton Sea

Description

Matrix derived from one foot contours of the Salton Sea floor. These data were created with the vertical datum NGVD29 and NAD83 California Teale Albers (EPSG:3110) projection. Each value in the matrix represents the elevation, in feet, of a 300 m x 300 m cell. Cell values are interpolated using a thin plate spline fit to an exhaustive sample of contour line vertices.

Usage

salton

Format

matrix, with cells representing X, Y grid locations, and attributes "crs" (containing WKT2019 string with coordinate reference system information) and "extent" (named numeric of length 4, containing xmin, xmax, ymin, ymax)

Source

California Division of Fish and Wildlife. 2007. Bathymetric Contours (1 foot) - Salton Sea (ds426). Available online: https://map.dfg.ca.gov/metadata/ds0426.html

Examples

str(salton)

# construct and georeference a SpatRaster object
dem <- terra::rast(salton)
terra::crs(dem) <- attr(salton, "crs")
terra::ext(dem) <- attr(salton, "extent")
names(dem) <- "Elevation (feet)"

dem

Elevation and SSURGO Soil Map Units for an Erosional Remnant in Calaveras County, California

Description

Co-registered 10 m Digital Elevation Model (DEM) and Soil Survey Geographic Database (SSURGO) soil map unit grid for an old erosional remnant landform that resembles a scorpion in Calaveras County, California, projected in NAD83 / Conus Albers (EPSG:5070). Elevation values (in meters) are aggregated from USGS 3DEP 1 m LiDAR data, and soil map unit keys (mukey) are rasterized from SSURGO map unit polygons onto the same 235 x 339 grid.

Usage

scorpion

Format

A named list with 3 elements and spatial attributes "crs" (WKT2019 string for EPSG:5070) and "extent" (numeric vector of length 4: xmin, xmax, ymin, ymax):

dem

Numeric matrix (235 x 339) of 10 m elevation values in meters.

mukey

Integer matrix (235 x 339) of SSURGO map unit keys (mukey).

mapunit

Data frame of SSURGO mapunit and muaggatt attributes with columns mukey (map unit key, used as the raster category ID), musym (map unit symbol), muname (map unit name), mukind (map unit kind), farmlndcl (farmland classification), slopegraddcp (representative slope gradient, dominant component, %), slopegradwta (weighted average slope gradient, %), drclassdcd (dominant drainage class), hydgrpdcd (dominant hydrologic soil group), and aws0100wta (available water storage 0-100 cm, cm). Suitable for assigning directly to a SpatRaster via levels(r) <- scorpion$mapunit.

Source

U.S. Geological Survey (USGS) 3D Elevation Program (3DEP) 1 m Digital Elevation Model, accessed via Google Earth Engine (⁠USGS/3DEP/1m⁠).

USDA Natural Resources Conservation Service (NRCS) Soil Survey Geographic Database (SSURGO), accessed via Soil Data Access (soilDB::SDA_spatialQuery() and soilDB::SDA_query()).

Examples

data("scorpion", package = "rgeomorphon")
str(scorpion)

# reconstruct elevation and soil map unit SpatRaster objects
dem <- terra::rast(scorpion$dem)
terra::crs(dem) <- attr(scorpion, "crs")
terra::ext(dem) <- attr(scorpion, "extent")
names(dem) <- "elevation"

soil <- terra::rast(scorpion$mukey)
terra::crs(soil) <- attr(scorpion, "crs")
terra::ext(soil) <- attr(scorpion, "extent")
levels(soil) <- scorpion$mapunit

c(dem, soil)