extract_soils_Miller1998_CONUSSoil: Extract soil information from the CONUSSoil soil dataset for...

View source: R/extract_soils_Miller1998_CONUSSoils.R

extract_soils_Miller1998_CONUSSoilR Documentation

Extract soil information from the CONUSSoil soil dataset for SOILWAT2 applications

Description

Extract soil information from the CONUSSoil soil dataset for SOILWAT2 applications

Usage

extract_soils_Miller1998_CONUSSoil(
  x,
  crs = 4326,
  path = ".",
  vars = c("bd", "rockvol", "sand", "clay", "silt"),
  lower_limits_by_vars = c(bd = 30, rockvol = 0, sand = 0, clay = 0, silt = 0),
  replace_missing_fragvol_with_zero = c("none", "all", "at_surface"),
  impute = FALSE,
  digits = 3L,
  verbose = FALSE
)

Arguments

x

A numerical two-dimensional object (a matrix, array, or data.frame) with longitude/X, latitude/Y as columns; a sp::SpatialPoints object; or a terra::SpatVector object; or a sf object with a point geometry, i.e., an object with a class sf or sfc.

crs

An object which is a crs or from which one can be derived. x can be numeric as a EPSG number; a character string as a wkt; a character string as a proj4 (not recommended because outdated); or of a class including raster::Raster, sp::Spatial, sp::CRS, or a sf or sfc class.

path

A character string. The path to the local copy of the CONUSSoil folder hierarchy, e.g., dirname(prepare_script_for_Miller1998_CONUSSoil()).

vars

A vector of character strings. The requested variables as used by CONUSSoil; see Miller et al. 1998.

lower_limits_by_vars

A named numeric vector. The names correspond to vars and values represent the lower limits that are conditioned/ masked out, i.e., set to NA.

replace_missing_fragvol_with_zero

A character string. Method indicating how missing/null values of rock/gravel fragment fractions should be interpreted; passed to set_missing_soils_to_value. The options are one of

"all"

Missing/null values of rack/gravel fragments are replaced by 0 See also argument nullFragsAreZero of function fetchSDA.

"at_surface"

Missing/null values of rack/gravel fragments are replaced by 0 Note, remaining missing values in deeper horizons can subsequently be imputed by argument impute.

"none"

Missing/null values remain unmodified unless argument impute is activated.

impute

A logical value. Impute missing values with a shallow-depth value carried deeper approach (in analogy to LOCF). Consequently, missing values in the shallowest horizon are not imputed. See impute_df.

digits

An integer value. The number of digits to which soil texture variables are rounded. Skip rounding if NA or NULL.

verbose

A logical value.

Notes

A local copy of CONUSSoil is required. The function prepare_script_for_Miller1998_CONUSSoil creates a script that can be used to download and prepare CONUSSoil files.

References

Miller, D. A., and R. A. White. 1998. A conterminous United States multilayer soil characteristics dataset for regional climate and hydrology modeling. Earth Interactions 2:1-26. http://www.soilinfo.psu.edu/index.cgi?soil_data&conus

See Also

extract

Examples

script_to_download_conussoil <- prepare_script_for_Miller1998_CONUSSoil()

## Execute script to download data
## (or set `path_conussoil` to your local copy)
path_conussoil <- dirname(script_to_download_conussoil)

## Mask out unrealistic variable values
has_CONUSSoil_cond <- create_conditioned_Miller1998_CONUSSoil(
  path = path_conussoil
)

## Check that we have CONUSSoil data
has_CONUSSoil <- isTRUE(all(
  check_Miller1998_CONUSSoil(path = path_conussoil)
))

if (has_CONUSSoil) {

  locations <- matrix(
    data = c(-120.1286878, -111.8511136, 39.8182913, 36.9047396),
    nrow = 2
  )

  res <- extract_soils_Miller1998_CONUSSoil(
    x = locations,
    path = path_conussoil,
    verbose = TRUE
  )
}

# Clean up example
unlink(script_to_download_conussoil)



DrylandEcology/rSW2exter documentation built on May 4, 2024, 10:53 p.m.