| fetchLDM | R Documentation |
This function provides access to the Kellogg Soil Survey Laboratory Data Mart (KSSL LDM) via Soil Data Access (SDA) or a local SQLite snapshot. See details and examples for additional usage instructions.
fetchLDM(
x = NULL,
what = "pedlabsampnum",
bycol = "pedon_key",
tables = c("lab_physical_properties", "lab_chemical_properties",
"lab_calculations_including_estimates_and_default_values", "lab_rosetta_Key"),
WHERE = NULL,
chunk.size = 1000,
ntries = 3,
layer_type = c("horizon", "layer", "reporting layer"),
area_type = c("ssa", "country", "state", "county", "mlra", "nforest", "npark"),
prep_code = c("S", "", "HM", "M", "N"),
analyzed_size_frac = c("<2 mm", ""),
dsn = NULL
)
x |
A vector of values to find in column specified by |
what |
A single column name from tables: |
bycol |
A single column name from |
tables |
A vector of table names; Default is
|
WHERE |
character. A custom SQL WHERE clause, which overrides |
chunk.size |
Number of pedons per chunk (for queries that may exceed
|
ntries |
Number of tries (times to halve |
layer_type |
Default: |
area_type |
Default: |
prep_code |
Character vector of laboratory preparation codes accepted
when querying tables with preparation-specific results. Default: |
analyzed_size_frac |
Default: |
dsn |
Data source name; either a path to a SQLite database, an open
DBIConnection or (default) |
You can download SQLite or GeoPackage snapshots here:
https://ncsslabdatamart.sc.egov.usda.gov/database_download.aspx. Specify
the dsn argument to use a local copy of the lab data rather than Soil Data
Access web service.
If the chunk.size parameter is set too large and the Soil Data Access
request fails, the algorithm will re-try the query with a smaller (halved)
chunk.size argument. This will be attempted up to 3 times before returning
NULL
prep_code "S" selects sieved, air-dried preparations; "" includes
records with no recorded preparation code; "HM" selects preparations for
heavy-metals analyses, generally intended to limit metal contamination; "M"
selects moist samples kept moist; and "N" selects air-dried preparations
where coarse-fragment content is unknown or unrecorded. A code can include
multiple preparation or size variants; use analyzed_size_frac to select
size fractions. Other preparation codes (for example, "F", "GP", and
"HM_SK") are excluded unless explicitly requested.
The default behavior joins the lab_area tables only for the "Soil Survey
Area" related records. You can specify alternative area records for use in
x, what or WHERE arguments by setting area_type to a different value.
When requesting data from "lab_major_and_trace_elements_and_oxides",
"lab_mineralogy_glass_count", or "lab_xray_and_thermal" multiple
preparation codes (prep_code) or size fractions (analyzed_size_frac) are
possible. The default behavior of fetchLDM() is to attempt to return a
topologically valid (minimal overlaps) SoilProfileCollection. This is
achieved by setting prep_code="S" ("sieved") and analyzed_size_frac="<2 mm". You may specify alternate or additional preparation codes or fractions
as needed, but note that this may cause "duplication" of some layers where
measurements were made with different preparation or on fractionated samples
a SoilProfileCollection for a successful query, a try-error if no site/pedon locations can be found or NULL for an empty lab_layer (within sites/pedons) result
## Not run:
# fetch by Soil Survey Area area symbol (area_code using default "ssa" area_type)
res <- fetchLDM("CA630", what = "area_code")
# fetch by Major Land Resource area symbol (area_code using "mlra" area_type)
res <- fetchLDM("22A", what = "area_code", area_type = "mlra")
# fetch by multiple case-insensitive taxon name
# (correlated or sampled as Musick or Holland series)
res <- fetchLDM(WHERE = "(CASE WHEN corr_name IS NOT NULL
THEN LOWER(corr_name)
ELSE LOWER(samp_name)
END) IN ('musick', 'holland')")
# physical properties of soils correlated as taxonomic subgroup "Typic Argialbolls"
res <- fetchLDM(x = "Typic Argialbolls",
what = "corr_taxsubgrp",
tables = "lab_physical_properties")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.