View source: R/extract_soils_NRCS_SDA.R
extract_soils_NRCS_SDA | R Documentation |
Extract soil information from the Soil Data Access SDA service by NRCS for SOILWAT2 applications
extract_soils_NRCS_SDA(
x,
crs = 4326,
mukeys = NULL,
method = c("SSURGO", "STATSGO", "SSURGO_then_STATSGO"),
sql_template = NA,
only_majcomp = TRUE,
only_soilcomp = TRUE,
remove_organic_horizons = c("none", "all", "at_surface"),
replace_missing_fragvol_with_zero = c("none", "all", "at_surface"),
estimate_missing_bulkdensity = FALSE,
restrict_by_ec_or_ph = TRUE,
impute = FALSE,
digits = 3L,
chunk_size = 1000L,
progress_bar = FALSE,
verbose = FALSE
)
x |
A numerical two-dimensional object
(a |
crs |
An object which is a crs or from which one can be derived.
|
mukeys |
A character or integer vector. List of soil map unit keys
for which soil information should be extracted. Provide |
method |
A character string. Method indicating whether SDA
should query "SSURGO", "STATSGO", or
"SSURGO_then_STATSGO" which attempts to replace
|
sql_template |
A character vector.
A valid |
only_majcomp |
A logical value. If |
only_soilcomp |
A logical value. If |
remove_organic_horizons |
A character string. Method
indicating how to deal with organic horizons as determined by
function |
replace_missing_fragvol_with_zero |
A character string. Method
indicating how missing/null values of rock/gravel fragment fractions
should be interpreted;
passed to
|
estimate_missing_bulkdensity |
A logical value. Estimate missing
bulk density values from saturated water content and gravel volume.
See |
restrict_by_ec_or_ph |
A logical value. Include depth restrictions
by |
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 |
digits |
An integer value. The number of digits to which soil texture
variables are rounded. Skip rounding if |
chunk_size |
An integer value. The size of chunks into which
|
progress_bar |
A logical value. Display a progress bar as the code loops over the chunks? |
verbose |
A logical value. |
NRCS soil datasets SSURGO and STATSGO are organized in soil map units mukey that are spatially explicit (i.e., we can query their values by geographic location) and within each mukey into soil map unit components cokey which have no explicit spatial arrangement within a soil map unit. Because soil texture information is specific to soil map unit components, geographic location alone is insufficient to query soil texture.
This function relies that soil information of exactly one cokey
per each location
or mukeys
is returned by
fetch_soils_from_NRCS_SDA
. The default SQL template
"nrcs_sql_template.sql" extracts the "dominant component".
The dominant component is defined as the the first cokey with the
highest representative component percent comppct_r that is a
soil component.
See GetDominantComponent.py
from https://github.com/ncss-tech/SoilDataDevelopmentToolbox.
Whereas mukey is expected to identify the same soil map unit across different releases of the NRCS database, a component cannot be tracked by its cokey across releases. A component of a soil map unit is best identified by a unique combination of compname, comppct_r, and localphase.
The argument remove_organic_horizons
is one of
All organic layers (at surface or buried) are removed and horizon number and depths are recalculated.
Organic layer(s) at the soil surface are removed and horizon number and depths are recalculated. Buried organic horizons remain unmodified.
Horizons are not modified.
A live internet connection is required to access SDA.
fetchSDA
and SDA_query
## Not run:
if (curl::has_internet()) {
locations <- matrix(
data = c(-120.325, -111.245, 39.855, 36.753),
nrow = 2
)
# Example 1: extract soils by mukey values
extract_soils_NRCS_SDA(mukeys = c(471168, 1606800))
# Example 2: extract soils by geographic location
extract_soils_NRCS_SDA(x = locations)
# Example 3: first identify mukey values by geographic location,
# then query soils from SSURGO by mukey,
# but still pass locations in case we need to query STATSGO as well
mukeys <- fetch_mukeys_spatially_NRCS_SDA(
x = locations,
db = "SSURGO",
progress_bar = TRUE
)
extract_soils_NRCS_SDA(
x = locations,
mukeys = mukeys[["mukeys"]],
method = "SSURGO_then_STATSGO",
remove_organic_horizons = "at_surface",
replace_missing_fragvol_with_zero = "at_surface",
estimate_missing_bulkdensity = TRUE,
restrict_by_ec_or_ph = FALSE,
impute = TRUE,
progress_bar = TRUE,
verbose = TRUE
)
}
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.