
Read a horizon spreadsheet (CSV/TSV) into a PedonRecord
Source:R/read-pedon-csv.R
read_pedon_csv.RdThe everyday entry point for anyone who has a soil profile in a spreadsheet:
one row per horizon, one column per attribute, using soilKey's canonical
column names (top_cm, bottom_cm, designation,
clay_pct, ph_h2o, munsell_hue_moist, ...). The full list
is names(horizon_column_spec()); the quickest start is the bundled
template
system.file("extdata", "perfil_exemplo.csv", package = "soilKey").
Arguments
- file
Path to a
.csv(comma) or.tsv(tab) file, one row per horizon.- site
Optional named list of site metadata (see
PedonRecord). Defaults tolist(id = <file base name>).- sep
Field separator.
"auto"(default) uses a tab for.tsvfiles and a comma otherwise.
Value
A PedonRecord.
Details
Only recognised columns are used (any extras are carried through untouched),
so a messy export still works: soilKey uses the columns it understands, and
recognises names that differ only in capitalisation or separators and common
aliases (Clay, SOC, CEC, ...). Columns and site
properties that it does not recognise are named in a warning, with the
closest recognised names (see unrecognised_attributes). Site
metadata (id, lat/lon, soil moisture / temperature regime)
is optional and passed via site; without it the profile still
classifies, just with less specificity where site data would have refined the
name.
See also
classify_csv to go straight from a file to the three
classifications; classify_all; PedonRecord.
Examples
f <- system.file("extdata", "perfil_exemplo.csv", package = "soilKey")
pedon <- read_pedon_csv(f)
classify_all(pedon)$summary
#> wrb
#> 1 Haplic Ferralsol (Clayic, Epic, Eutric, Humic)
#> sibcs
#> 1 Latossolos Vermelhos Distróficos típicos, textura argilosa, A moderado
#> usda
#> 1 Typic Hapludox