Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# soilDB (development)
- WCS specifications now managed server-side via SoilWeb

# soilDB 2.9.3 (2026-09-17)
- `createSSURGO()` fix bug in logical column handling (introduced in 2.9.2) due to metadata column type enforcement (#483)
- Fix `structure()` usage of special argument names (.Label, .Names) in test fixtures for R-devel (#484)
Expand Down
110 changes: 57 additions & 53 deletions R/ISSR800.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,55 +23,55 @@
#'
#' Variables available from this WCS can be queried using \code{WCS_details(wcs = 'ISSR800')}.
#'
#' |var |crs |description |
#' |:----------------|:---------|:------------------------------------------------------|
#' |caco3_kg_sq_m |EPSG:5070 |Total CaCO3 (kg/m^2) |
#' |cec_025cm |EPSG:5070 |CEC at pH 7 0-25cm depth (cmol[+]/kg) |
#' |cec_050cm |EPSG:5070 |CEC at pH 7 0-50cm depth (cmol[+]/kg) |
#' |cec_05cm |EPSG:5070 |CEC at pH 7 0-5cm depth (cmol[+]/kg) |
#' |clay_025cm |EPSG:5070 |clay percent 0-25cm depth |
#' |clay_05cm |EPSG:5070 |clay percent 0-5cm depth |
#' |clay_2550cm |EPSG:5070 |clay percent 25-50cm depth |
#' |clay_3060cm |EPSG:5070 |clay percent 30-60cm depth |
#' |drainage_class |EPSG:5070 |Soil Drainage Class |
#' |ec_025cm |EPSG:5070 |EC 0-25cm depth (dS/m) |
#' |ec_05cm |EPSG:5070 |EC 0-5cm depth (dS/m) |
#' |greatgroup |EPSG:5070 |Soil Taxonomy: Greatgroup |
#' |hydgrp |EPSG:5070 |Hydrologic Soil Group |
#' |lcc_irrigated |EPSG:5070 |Land Capability Class, irrigated |
#' |lcc_nonirrigated |EPSG:5070 |Land Capability Class, non-irrigated |
#' |n_components |EPSG:5070 |Number of components per grid cell |
#' |n_polygons |EPSG:5070 |Number of polygons per grid cell |
#' |om_kg_sq_m |EPSG:5070 |Total Soil Organic Matter (kg/m^2) |
#' |paws |EPSG:5070 |total plant available water storage (cm water) |
#' |paws_025cm |EPSG:5070 |plant available water storage 0-25cm depth (cm water) |
#' |paws_050cm |EPSG:5070 |plant available water storage 0-50cm depth (cm water) |
#' |ph_025cm |EPSG:5070 |pH 1:1 H2O 0-25cm depth |
#' |ph_05cm |EPSG:5070 |pH 1:1 H2O 0-5cm depth |
#' |ph_2550cm |EPSG:5070 |pH 1:1 H2O 25-50cm depth |
#' |ph_3060cm |EPSG:5070 |pH 1:1 H2O 30-60cm depth |
#' |sand_025cm |EPSG:5070 |sand percent 0-25cm depth |
#' |sand_05cm |EPSG:5070 |sand percent 0-5cm depth |
#' |sand_2550cm |EPSG:5070 |sand percent 25-50cm depth |
#' |sand_3060cm |EPSG:5070 |sand percent 30-60cm depth |
#' |sar |EPSG:5070 |SAR, entire profile |
#' |series_name |EPSG:5070 |Soil Series Name |
#' |silt_025cm |EPSG:5070 |silt percent 0-25cm depth |
#' |silt_05cm |EPSG:5070 |silt percent 0-5cm depth |
#' |silt_2550cm |EPSG:5070 |silt percent 25-50cm depth |
#' |silt_3060cm |EPSG:5070 |silt percent 30-60cm depth |
#' |soilorder |EPSG:5070 |Soil Taxonomy: Soil Order |
#' |ssurgo_pct |EPSG:5070 |SSURGO data available, fraction of 800x800m grid cell |
#' |statsgo_pct |EPSG:5070 |STATSGO data available, fraction of 800x800m grid cell |
#' |str |EPSG:5070 |Soil Temperature Regime |
#' |suborder |EPSG:5070 |Soil Taxonomy: Suborder |
#' |survey_type |EPSG:5070 |Soil survey data source |
#' |texture_025cm |EPSG:5070 |Soil Texture Class, 0-25cm |
#' |texture_05cm |EPSG:5070 |Soil Texture Class, 0-5cm |
#' |texture_2550cm |EPSG:5070 |Soil Texture Class, 25-50cm |
#' |weg |EPSG:5070 |Wind Erodibility Group |
#' |wei |EPSG:5070 |Wind Erodibility Index |
#'
#' |var |vintage |crs |description |
#' |:----------------|:-------|:---------|:------------------------------------------------------|
#' |caco3_kg_sq_m |FY2027 |EPSG:5070 |Total CaCO3 (kg/m^2) |
#' |cec_025cm |FY2027 |EPSG:5070 |CEC at pH 7 0-25cm depth (cmol[+]/kg) |
#' |cec_050cm |FY2027 |EPSG:5070 |CEC at pH 7 0-50cm depth (cmol[+]/kg) |
#' |cec_05cm |FY2027 |EPSG:5070 |CEC at pH 7 0-5cm depth (cmol[+]/kg) |
#' |clay_025cm |FY2027 |EPSG:5070 |clay percent 0-25cm depth |
#' |clay_05cm |FY2027 |EPSG:5070 |clay percent 0-5cm depth |
#' |clay_2550cm |FY2027 |EPSG:5070 |clay percent 25-50cm depth |
#' |clay_3060cm |FY2027 |EPSG:5070 |clay percent 30-60cm depth |
#' |drainage_class |FY2027 |EPSG:5070 |Soil Drainage Class |
#' |ec_025cm |FY2027 |EPSG:5070 |EC 0-25cm depth (dS/m) |
#' |ec_05cm |FY2027 |EPSG:5070 |EC 0-5cm depth (dS/m) |
#' |greatgroup |FY2027 |EPSG:5070 |Soil Taxonomy: Greatgroup |
#' |hydgrp |FY2027 |EPSG:5070 |Hydrologic Soil Group |
#' |lcc_irrigated |FY2027 |EPSG:5070 |Land Capability Class, irrigated |
#' |lcc_nonirrigated |FY2027 |EPSG:5070 |Land Capability Class, non-irrigated |
#' |n_components |FY2027 |EPSG:5070 |Number of components per grid cell |
#' |n_polygons |FY2027 |EPSG:5070 |Number of polygons per grid cell |
#' |om_kg_sq_m |FY2027 |EPSG:5070 |Total Soil Organic Matter (kg/m^2) |
#' |paws |FY2027 |EPSG:5070 |total plant available water storage (cm water) |
#' |paws_025cm |FY2027 |EPSG:5070 |plant available water storage 0-25cm depth (cm water) |
#' |paws_050cm |FY2027 |EPSG:5070 |plant available water storage 0-50cm depth (cm water) |
#' |ph_025cm |FY2027 |EPSG:5070 |pH 1:1 H2O 0-25cm depth |
#' |ph_05cm |FY2027 |EPSG:5070 |pH 1:1 H2O 0-5cm depth |
#' |ph_2550cm |FY2027 |EPSG:5070 |pH 1:1 H2O 25-50cm depth |
#' |ph_3060cm |FY2027 |EPSG:5070 |pH 1:1 H2O 30-60cm depth |
#' |sand_025cm |FY2027 |EPSG:5070 |sand percent 0-25cm depth |
#' |sand_05cm |FY2027 |EPSG:5070 |sand percent 0-5cm depth |
#' |sand_2550cm |FY2027 |EPSG:5070 |sand percent 25-50cm depth |
#' |sand_3060cm |FY2027 |EPSG:5070 |sand percent 30-60cm depth |
#' |sar |FY2027 |EPSG:5070 |SAR, entire profile |
#' |series_name |FY2027 |EPSG:5070 |Soil Series Name |
#' |silt_025cm |FY2027 |EPSG:5070 |silt percent 0-25cm depth |
#' |silt_05cm |FY2027 |EPSG:5070 |silt percent 0-5cm depth |
#' |silt_2550cm |FY2027 |EPSG:5070 |silt percent 25-50cm depth |
#' |silt_3060cm |FY2027 |EPSG:5070 |silt percent 30-60cm depth |
#' |soilorder |FY2027 |EPSG:5070 |Soil Taxonomy: Soil Order |
#' |ssurgo_pct |FY2027 |EPSG:5070 |SSURGO data available, fraction of 800x800m grid cell |
#' |statsgo_pct |FY2027 |EPSG:5070 |STATSGO data available, fraction of 800x800m grid cell |
#' |str |FY2027 |EPSG:5070 |Soil Temperature Regime |
#' |suborder |FY2027 |EPSG:5070 |Soil Taxonomy: Suborder |
#' |survey_type |FY2027 |EPSG:5070 |Soil survey data source |
#' |texture_025cm |FY2027 |EPSG:5070 |Soil Texture Class, 0-25cm |
#' |texture_05cm |FY2027 |EPSG:5070 |Soil Texture Class, 0-5cm |
#' |texture_2550cm |FY2027 |EPSG:5070 |Soil Texture Class, 25-50cm |
#' |weg |FY2027 |EPSG:5070 |Wind Erodibility Group |
#' |wei |FY2027 |EPSG:5070 |Wind Erodibility Index |
#'
#' @note There are still some issues to be resolved related to the encoding of NA Variables with a natural zero (e.g. SAR) have 0 set to NA.
#'
#' @return `SpatRaster` (or `RasterLayer`) object, or `try-error` if the WCS request fails.
Expand All @@ -92,9 +92,6 @@
#' @export
ISSR800.wcs <- function(aoi, var, res = 800, quiet = FALSE) {

# vintage of source data
.vintage <- 'FY2027'

if (!requireNamespace("terra")) {
stop("package 'terra' is required", call. = FALSE)
}
Expand All @@ -109,6 +106,13 @@ ISSR800.wcs <- function(aoi, var, res = 800, quiet = FALSE) {
stop('`res` should be within 400 <= res <= 1600 meters')
}

# try loading WCS specifications from SoilWeb
.ISSR800.spec <- try(fromJSON('https://casoilresource.lawr.ucdavis.edu/wcs/issr800.json'), silent = TRUE)

if(inherits(.ISSR800.spec, 'try-error')) {
stop('WCS spec not available', call. = FALSE)
}

# match variable name in catalog
var.cat <- sapply(.ISSR800.spec, '[[', 'dsn')
var <- match.arg(tolower(var), choices = var.cat)
Expand Down Expand Up @@ -285,7 +289,7 @@ ISSR800.wcs <- function(aoi, var, res = 800, quiet = FALSE) {
}

# set metadata
terra::metags(r) <- c(description = var.spec$desc, vintage = .vintage)
terra::metags(r) <- c(description = var.spec$desc, vintage = var.spec$vintage)

return(r)
}
Expand Down
Loading
Loading