| 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 |
forms_matrix objectThis constructor function wraps a 9x9 integer matrix and associates it with a set of levels, creating a 'forms_matrix' object.
forms_matrix(x, levels = get_forms_grass_enum())forms_matrix(x, levels = get_forms_grass_enum())
x |
Integer. A 9x9 matrix. |
levels |
Named integer vector. Map of integer values to their string
names. Default: |
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.
An object of class c("forms_matrix", "matrix", "array").
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)))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)))
forms_matrix to Positive and Negative OverlooksThis function applies a forms_matrix to reclassify a SpatRaster object with
2 layers containing positive and negative overlooks.
forms_matrix_apply( x, rcl = forms_matrix_get(), positive = "positive", negative = "negative", ... )forms_matrix_apply( x, rcl = forms_matrix_get(), positive = "positive", negative = "negative", ... )
x |
SpatRaster containing two layers with names specified in |
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:
|
negative |
Character. Layer name of negative count. Default:
|
... |
Additional arguments passed to |
A SpatRaster containing the classification result.
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))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))
forms_matrix for Geomorphon ClassificationGets 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)
forms_matrix_get(num_forms = 10, levels = get_forms_grass_enum())forms_matrix_get(num_forms = 10, levels = get_forms_grass_enum())
num_forms |
Integer. The number of forms to classify, one of |
levels |
Named integer with values between 0 and 10 corresponding to
form class labels. Default: |
For creating custom classification systems see the forms_matrix() constructor.
An object of class forms_matrix
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)
forms_matrix_get()forms_matrix_get()
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.
geomorphon_calibrate( sweep_obj, targets, forms = NULL, method = c("both", "nmi", "boundary"), threshold_cells = 2, spatial_null = TRUE )geomorphon_calibrate( sweep_obj, targets, forms = NULL, method = c("both", "nmi", "boundary"), threshold_cells = 2, spatial_null = TRUE )
sweep_obj |
An object of class |
targets |
A single- or multi-layer categorical |
forms |
Character vector of form taxonomies to evaluate (e.g.
|
method |
Character concordance method: |
threshold_cells |
Integer or numeric cell distance tolerance for boundary
metrics. Default is |
spatial_null |
Logical. Whether to evaluate spatial-null circular shift
ensembles in |
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.
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)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)
Applies standard class names and colors to a SpatRaster, or creates a factor matrix. Input values should be integers between 1 and 10.
geomorphon_categories() geomorphon_colors() geomorphon_theme(x, forms = "forms10")geomorphon_categories() geomorphon_colors() geomorphon_theme(x, forms = "forms10")
x |
A SpatRaster or matrix object. |
forms |
character. One of: |
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.
A SpatRaster or matrix object with geomorphon class names (and colors for SpatRaster) applied.
geomorphon_theme(1:10)geomorphon_theme(1:10)
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.
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) )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) )
x |
A SpatRaster object. |
workers |
integer. Number of parallel workers. Default uses value of
environment variable |
scl_need |
numeric. Scaling factor for memory needs. Default uses
value of environment variable |
scl_workers |
numeric. Scaling factor for each worker. Default uses
value of environment variable |
pow_total |
numeric. Exponent for scaling total number of chunks.
Default uses value of environment variable |
integer. Number of tile chunks to divide x into.
data("salton", package = "rgeomorphon") x <- terra::rast(salton) terra::ext(x) <- attr(salton, "extent") terra::crs(x) <- attr(salton, "crs") geomorphon_chunks_needed(x)data("salton", package = "rgeomorphon") x <- terra::rast(salton) terra::ext(x) <- attr(salton, "extent") terra::crs(x) <- attr(salton, "crs") geomorphon_chunks_needed(x)
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.
geomorphon_concordance( geo_rast, cat_rast, method = c("both", "nmi", "boundary"), threshold_cells = 2, spatial_null = TRUE )geomorphon_concordance( geo_rast, cat_rast, method = c("both", "nmi", "boundary"), threshold_cells = 2, spatial_null = TRUE )
geo_rast |
|
cat_rast |
|
method |
Character. Which concordance metrics to calculate. One of
|
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 |
spatial_null |
Logical. Whether to calculate the spatial-null ensemble.
If |
A list with the following components (depending on method):
nmiNumeric. Normalized Mutual Information (0-1). Higher values indicate stronger statistical association between classifications. Existing NMI behavior is unchanged. Only included when method includes "nmi".
homogeneityNumeric. 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".
completenessNumeric. 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_offsetNumeric. 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_concordanceNumeric. 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_f1Numeric. Symmetric threshold-based boundary F1 (0-1).
NA_real_ if either shared-domain boundary set is empty. Included
when method includes "boundary".
edge_mhdNumeric. 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_chamferNumeric. 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_cellsInteger. Total number of valid cells analyzed.
n_edges_geoInteger. Number of geomorphon boundary cells. Only included when method includes "boundary".
n_edges_catInteger. Number of categorical boundary cells. Only included when method includes "boundary".
contingency_tableMatrix. Cross-tabulation of geomorphon vs. categorical classes. Only included when method includes "nmi".
class_homogeneityNumeric 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_completenessNumeric 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_nmiNumeric. 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_nmiNumeric. 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_shiftsInteger. 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_f1Numeric. 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_f1Numeric. 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_shiftsInteger. Number of evaluated shifts eligible for the edge-F1 null mean (both edge sets nonempty). Included only for methods "boundary" and "both".
null_shifts_evaluatedInteger. Number of non-identity shifts evaluated for the null ensemble, shared by the requested metrics.
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 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.
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
geomorphons(), terra::boundaries()
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")])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")])
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.
geomorphon_divergence(p, q, method = "jensen-shannon", unit = "log2")geomorphon_divergence(p, q, method = "jensen-shannon", unit = "log2")
p |
A multi-layer class-proportion |
q |
A multi-layer class-proportion |
method |
Character distance metric. Default is |
unit |
Logarithm unit. Default is |
A list containing:
raster |
A single-layer |
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. |
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_divergencelibrary(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
Computes cell-wise ensemble summaries across parameter sweep runs, supporting deterministic modal classification and per-class proportion layers.
geomorphon_ensemble( sweep_obj, method = c("modal", "proportions"), form = NULL, classes = NULL, ties = "lowest", ... )geomorphon_ensemble( sweep_obj, method = c("modal", "proportions"), form = NULL, classes = NULL, ties = "lowest", ... )
sweep_obj |
An object of class |
method |
character. Aggregation method: |
form |
character or numeric. Which form taxonomy to aggregate when multiple
exist in |
classes |
integer or character vector. Which landform classes to compute
proportions for when |
ties |
character. Tie-breaking rule for |
... |
Additional arguments passed to methods. |
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.
## 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)## 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)
Identifies non-dominated Pareto-optimal parameter sets and computes composite harmonic-mean scores over multi-objective evaluation tables.
geomorphon_pareto( cal_df, objectives = NULL, by = "target", min_edge_ratio = 0, max_edge_ratio = Inf )geomorphon_pareto( cal_df, objectives = NULL, by = "target", min_edge_ratio = 0, max_edge_ratio = Inf )
cal_df |
A |
objectives |
Named character vector defining optimization directions for
each objective (e.g. |
by |
Character vector of column names defining independent Pareto grouping
domains. Default is |
min_edge_ratio |
Minimum permissible |
max_edge_ratio |
Maximum permissible |
The input cal_df augmented with:
is_pareto |
Logical. |
pareto_score |
Numeric in |
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)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)
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.
geomorphon_profile_dist( x, margin = 1, method = "jensen-shannon", unit = "log2" )geomorphon_profile_dist( x, margin = 1, method = "jensen-shannon", unit = "log2" )
x |
A |
margin |
Integer indicating the profile direction: |
method |
Character string specifying distance metric. Default is |
unit |
Logarithm unit ( |
A symmetric numeric distance matrix with row and column names matching the profile labels.
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)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)
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.
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, ... )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, ... )
x |
|
mode |
Character. One of |
search |
Numeric. Search radius for geomorphon calculation (only used
when |
skip |
Numeric. Skip radius for geomorphon calculation (only used when
|
flat_angle_deg |
Numeric. Flatness angle threshold in degrees (only
used when |
dist |
Numeric. Flatness distance (only used when |
forms |
Character. Form system to use: |
coefficients |
Named numeric vector. Custom PTRM coefficients for each
geomorphon class. If |
intercept |
Numeric. PTRM intercept. Default: |
normalizer |
Numeric. PTRM divisor. Must be finite and non-zero.
Default: |
... |
Additional arguments passed to |
A list containing:
ptrm_scoreNumeric. 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_scoreNumeric. Unnormalized score before division.
proportionsNamed numeric vector. Proportion of each observed geomorphon form in the input, named with the canonical system labels.
n_cellsInteger. Total number of valid (non-NA) cells analyzed.
The geomorphon classification algorithm assumes planar distances, so it is strongly recommended that elevation data be in a projected coordinate system.
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:
where is the intercept (-38.02 by default), are the
coefficients for each geomorphon form, are the proportions of each
form in the terrain, and 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.
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
geomorphons(), geomorphon_categories()
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)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)
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.
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, ... )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, ... )
x |
|
radius |
Numeric. Integer window radius in cells (not map units). Default: 3. Larger values compute PTRM from larger neighborhoods. |
mode |
Character. Input type: |
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 |
forms |
Character. Form system to use: |
intercept |
Numeric. PTRM intercept. Default: |
normalizer |
Numeric. PTRM normalizer; must be finite and non-zero.
Default: |
search |
Numeric. Search radius for geomorphon calculation (only used
when |
skip |
Numeric. Skip radius for geomorphon calculation (only used when
|
flat_angle_deg |
Numeric. Flatness angle threshold in degrees (only used
when |
dist |
Numeric. Flatness distance parameter (only used when |
filename |
Character. Output filename. If provided, the result is written
to disk instead of returned in memory. Default: |
overwrite |
Logical. Overwrite existing file? Default: |
... |
Additional arguments passed to |
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
A SpatRaster with raw focal PTRM scores. Values are not normalized to
[0, 1] and may fall outside that range. Border cells are NA.
Uses a two-pass approach for efficiency:
Calculate geomorphons globally (if mode = "dem")
Applies the full geomorphon classification algorithm once
Produces classification raster with classes 1-10
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).
Uses a circular window based on Euclidean distance. For an integer
radius = r, includes all cells where sqrt(dx^2 + dy^2) <= r.
Cells within radius distance of raster edges are set to NA, as their
neighborhoods are incomplete. This prevents edge artifacts in the output.
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.
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
geomorphon_ptrm(), geomorphons(), terra::focal()
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)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)
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.
geomorphon_sweep( elevation, param_grid, forms = c("forms10", "forms6", "forms5", "forms4"), ... )geomorphon_sweep( elevation, param_grid, forms = c("forms10", "forms6", "forms5", "forms4"), ... )
elevation |
A |
param_grid |
A |
forms |
character or numeric vector. Landform taxonomies to compute
for each parameter combination. Default is
|
... |
Additional arguments passed to |
An S3 object of class geomorphon_sweep containing:
summary |
A tidy |
rasters |
A named list of classification outputs (one per run_id). |
## 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)## 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)
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.
geomorphon_targets( x, attrs = NULL, id_col = 1, vars = NULL, breaks = list(), labels = list(), right = TRUE )geomorphon_targets( x, attrs = NULL, id_col = 1, vars = NULL, breaks = list(), labels = list(), right = TRUE )
x |
A single-layer categorical or integer |
attrs |
Optional |
id_col |
Column index or column name in |
vars |
Character vector of column names in |
breaks |
Named list of numeric break vectors for binning continuous
attribute columns using |
labels |
Named list of character vectors of category labels corresponding
to |
right |
Logical. Indicating if the intervals should be closed on the right
(and open on the left) or vice versa. Default is |
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_classes |
Number of factor levels / distinct categories. |
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")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")
'Rcpp' implementation of the geomorphon terrain classification system based on 'r.geomorphon' algorithm of Jasiewicz and Stepinski (2013) from 'GRASS GIS'.
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) )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) )
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 |
search |
numeric. User input for search radius (default: |
skip |
numeric. User input for skip radius (default: |
flat_angle_deg |
numeric. Flatness angle threshold in degrees.
Default: |
dist |
numeric. Flatness distance (default: |
comparison_mode |
Character. One of |
tdist |
numeric. Terrain distance factor. When greater than 0, overrides
Z tolerance from angular logic. Default: |
forms |
character. Number of geomorphon forms to identify. One of
|
ternary |
logical. Include "ternary" output? Default: |
positive |
logical. Include "positive" output? Default: |
negative |
logical. Include "negative" output? Default: |
use_meters |
Logical. Default: |
nodata_val |
numeric. NODATA value. Default: |
xres |
numeric. X grid resolution (used only when |
yres |
numeric. Y grid resolution (used only when |
simplify |
logical. If result is length |
LAPPLY.FUN |
An |
nchunk |
Number of tile chunks to use. Default: |
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.
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.
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.
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.
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)
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)
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
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)
geomorphon_theme() geomorphon_chunks_needed()
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))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))
Controls how the 'forms_matrix' object is displayed in the console.
## S3 method for class 'forms_matrix' print(x, show_values = FALSE, ...)## S3 method for class 'forms_matrix' print(x, show_values = FALSE, ...)
x |
The |
show_values |
A logical value. If |
... |
Additional arguments passed to print (not used here). |
Invisibly returns the original object x.
print(forms_matrix_get(num_forms = 4))print(forms_matrix_get(num_forms = 4))
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.
saltonsalton
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)
California Division of Fish and Wildlife. 2007. Bathymetric Contours (1 foot) - Salton Sea (ds426). Available online: https://map.dfg.ca.gov/metadata/ds0426.html
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)" demstr(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
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.
scorpionscorpion
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):
demNumeric matrix (235 x 339) of 10 m elevation values in meters.
mukeyInteger matrix (235 x 339) of SSURGO map unit keys (mukey).
mapunitData 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.
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()).
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)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)