View source: R/extract_soils_NRCS_SDA.R
fetch_soils_from_NRCS_SDA | R Documentation |
NRCS
SDA
web serviceDownload soil data from NRCS
SDA
web service
fetch_soils_from_NRCS_SDA(
mukeys_unique,
bind_params = mukeys_unique,
sql_template = NA,
injection_format = "mukey IN (%s)",
majcompflag = c("subset", "ignore"),
only_soilcomp = TRUE,
chunk_size = 1000L,
progress_bar = FALSE
)
mukeys_unique |
An integer vector with unique |
bind_params |
A vector or 2-dimensional container with parameter values
to bind to the |
sql_template |
A character vector.
A valid |
injection_format |
A character vector that identifies the location
(format specifier) in |
majcompflag |
A character string. |
only_soilcomp |
A logical value. 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? |
A data.frame
according to the specifications of sql
or
NULL
if the query returns empty.
A live internet connection is required to access SDA
.
This is a function with minimal functionality;
use extract_soils_NRCS_SDA()
for a user-friendly interface.
soilDB::SDA_query()
## Not run:
if (curl::has_internet()) {
# Query soils of dominant component of soil map unit
fetch_soils_from_NRCS_SDA(bind_params = 67616)
# As of 2022-March-15, mukey 2479921 contained one "NOTCOM" component
fetch_soils_from_NRCS_SDA(bind_params = 2479921)
fetch_soils_from_NRCS_SDA(bind_params = 2479921, only_soilcomp = FALSE)
sql <- readLines(
system.file("NRCS", "nrcs_sql_template.sql", package = "rSW2exter")
)
fetch_soils_from_NRCS_SDA(bind_params = 67616, sql_template = sql)
# This will return NULL because -1 is not an existing mukey value
fetch_soils_from_NRCS_SDA(bind_params = -1, sql_template = sql)
# Query soils of a specific component of a soil map unit
sql2 <- readLines(
system.file("NRCS", "nrcs_sql_template2.sql", package = "rSW2exter")
)
fetch_soils_from_NRCS_SDA(
bind_params = data.frame(mukey = 398856, compname = "Waupaca"),
sql_template = sql2,
injection_format = "(VALUES %s) AS t (mm, cn)"
)
}
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.