From bd675ee843e457a06f45be7d75f3d4ce66a8e732 Mon Sep 17 00:00:00 2001 From: Andrew Gene Brown Date: Fri, 4 Oct 2024 17:22:46 -0700 Subject: [PATCH] get_SDA_hydric: fix dominant condition --- R/get_SDA_hydric.R | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/R/get_SDA_hydric.R b/R/get_SDA_hydric.R index 64acdf20..e87143f6 100644 --- a/R/get_SDA_hydric.R +++ b/R/get_SDA_hydric.R @@ -94,12 +94,14 @@ get_SDA_hydric <- function(areasymbols = NULL, } if (method == "DOMINANT CONDITION") { - hyd_selection <- sprintf("AND hydricrating = (%s)", .LIMIT_N(sprintf("SELECT hydricrating FROM mapunit AS mu - GROUP BY hydricrating, comppct_r - ORDER BY SUM(comppct_r) OVER (PARTITION BY hydricrating) DESC", - ifelse(miscellaneous_areas, "", " AND NOT c.compkind = 'Miscellaneous area'"), - ifelse(include_minors, "", " AND c.majcompflag = 'Yes'")), - n = 1, sqlite = !is.null(dsn))) + hyd_selection <- sprintf("AND hydricrating = (%s)", + .LIMIT_N(sprintf("SELECT hydricrating FROM mapunit AS mu + INNER JOIN component ON component.mukey = mapunit.mukey %s %s + GROUP BY hydricrating, comppct_r + ORDER BY SUM(comppct_r) OVER (PARTITION BY hydricrating) DESC", + ifelse(miscellaneous_areas, "", " AND NOT component.compkind = 'Miscellaneous area'"), + ifelse(include_minors, "", " AND component.majcompflag = 'Yes'")), + n = 1, sqlite = !is.null(dsn))) } q <- sprintf(paste0("SELECT areasymbol, musym, muname, mapunit.mukey, ",