Skip to content

Commit

Permalink
harmonize hzID in fetchX() functions - resolves #113
Browse files Browse the repository at this point in the history
  • Loading branch information
brownag committed Nov 6, 2019
1 parent 49b9f15 commit 4ca51ce
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 1 deletion.
3 changes: 3 additions & 0 deletions R/fetchKSSL.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ fetchKSSL <- function(series=NULL, bbox=NULL, mlra=NULL, pedlabsampnum=NULL, ped

} else m <- NULL

# set KSSL-specific horizon identifier
hzidname(h) <- "labsampnum"

## set metadata
h.metadata <- metadata(h)
h.metadata$origin <- 'KSSL via Soilweb / fetchKSSL'
Expand Down
2 changes: 2 additions & 0 deletions R/fetchNASISLabData.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ fetchNASISLabData <- function() {
# add site data to object
site(h) <- s # left-join via labpeiid

# set NASIS-specific horizon identifier
hzidname(h) <- 'phiid'

# 7. save and mention bad pedons
assign('bad.labpedon.ids', value=bad.pedon.ids, envir=soilDB.env)
Expand Down
3 changes: 3 additions & 0 deletions R/fetchNASIS_components.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ fetchNASIS_components <- function(SS=TRUE, rmHzErrors=TRUE, fill = FALSE, string
if(length(get("component.hz.problems", envir = soilDB.env)) > 0)
message("-> QC: horizon errors detected, use `get('component.hz.problems', envir=soilDB.env)` for related coiid values")

# set NASIS component specific horizon identifier
hzidname(f.chorizon) <- 'chiid'

# set metadata
m <- metadata(f.chorizon)
m$origin <- 'NASIS components'
Expand Down
3 changes: 3 additions & 0 deletions R/fetchNASIS_pedons.R
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ fetchNASIS_pedons <- function(SS=TRUE, rmHzErrors=TRUE, nullFragsAreZero=TRUE, s
m$origin <- 'NASIS pedons'
metadata(h) <- m

# set NASIS-specific horizon identifier
hzidname(h) <- 'phiid'

# print any messages on possible data quality problems:
if(exists('sites.missing.pedons', envir=soilDB.env))
if(length(get('sites.missing.pedons', envir=soilDB.env)) > 0)
Expand Down
3 changes: 3 additions & 0 deletions R/fetchPedonPC.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ fetchPedonPC <- function(dsn) {
if(nrow(lf) > 0)
site(h) <- lf

# set PedonPC/NASIS-specific horizon identifier
hzidname(h) <- 'phiid'

# 7. save and mention bad pedons
assign('bad.pedon.ids', value=bad.pedon.ids, envir=soilDB.env)
if(length(bad.pedon.ids) > 0)
Expand Down
3 changes: 3 additions & 0 deletions R/fetchRaCA.R
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ fetchRaCA <- function(series=NULL, bbox=NULL, state=NULL, rcasiteid=NULL, get.vn
s$region <- substr(s$rcasiteid, 2, 3)
s$soilgroup <- substr(s$rcasiteid, 2, 5)

# set NASIS-specific horizon identifier
hzidname(h) <- 'phiid'

# merge-in site data
site(h) <- s

Expand Down
3 changes: 3 additions & 0 deletions R/get_component_from_LIMS.R
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@ fetchNASISWebReport <- function(projectname, rmHzErrors = FALSE, fill = FALSE,
# add site data to object
site(f.chorizon) <- f.component # left-join via cokey

# set SDA/SSURGO-specific horizon identifier
hzidname(f.chorizon) <- 'chkey'

# print any messages on possible data quality problems:
if (exists('component.hz.problems', envir=soilDB.env))
message("-> QC: horizon errors detected, use `get('component.hz.problems', envir=soilDB.env)` for related cokey values")
Expand Down
5 changes: 4 additions & 1 deletion R/get_component_from_SDA.R
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,10 @@ fetchSDA_component <- function(WHERE = NULL, duplicates = FALSE, childs = TRUE,
## TODO: make this error more informative
# add site data to object
site(f.chorizon) <- f.component # left-join via cokey


# set SDA/SSURGO-specific horizon identifier
hzidname(f.chorizon) <- 'chkey'

# add diagnostics
if(is.data.frame(f.diag)) {
diagnostic_hz(f.chorizon) <- f.diag
Expand Down

0 comments on commit 4ca51ce

Please sign in to comment.