This function inspects a SoilProfileCollection object, looking for four common errors in horizon depths:

  1. bottom depth shallower than top depth

  2. equal top and bottom depth

  3. missing top or bottom depth (e.g. NA)

  4. gap or overlap between adjacent horizons

  hzdepths = NULL,
  idname = NULL,
  fast = FALSE,
  byhz = FALSE



SoilProfileCollection or data.frame object to check


SoilProfileCollection uses horizonDepths(x) Default: NULL; if x is a data.frame, character vector of column names of top and bottom depths


SoilProfileCollection uses idname(x) Default: NULL; if x is a data.frame, character vector with column name of unique profile ID;


If details about specific test results are not needed, the operation can allocate less memory and run approximately 5x faster. Default: FALSE


Apply logic tests to profiles or individual horizons?


A data.frame containing profile IDs, validity boolean (valid) and test results if fast = FALSE.

The data.frame will have as many rows as profiles in x (length(x)).

  • id : Profile IDs, named according to idname(x)

  • valid : boolean, profile passes all of the following tests

    • depthLogic : boolean, errors related to depth logic

    • sameDepth : boolean, errors related to same top/bottom depths

    • missingDepth : boolean, NA in top / bottom depths

    • overlapOrGap : boolean, gaps or overlap in adjacent horizons


D.E. Beaudette, A.G. Brown, S.M. Roecker


## sample data

depths(sp3) <- id ~ top + bottom

# these data should be clean
res <- checkHzDepthLogic(sp3)

#>   id valid depthLogic sameDepth missingDepth overlapOrGap
#> 1  1  TRUE      FALSE     FALSE        FALSE        FALSE
#> 2 10  TRUE      FALSE     FALSE        FALSE        FALSE
#> 3  2  TRUE      FALSE     FALSE        FALSE        FALSE
#> 4  3  TRUE      FALSE     FALSE        FALSE        FALSE
#> 5  4  TRUE      FALSE     FALSE        FALSE        FALSE
#> 6  5  TRUE      FALSE     FALSE        FALSE        FALSE

# less memory if only concerned about net validity
res <- checkHzDepthLogic(sp3, fast = TRUE)

#>   id valid
#> 1  1  TRUE
#> 2 10  TRUE
#> 3  2  TRUE
#> 4  3  TRUE
#> 5  4  TRUE
#> 6  5  TRUE