Closed brownag closed 1 year ago
That is strange! I'll have to investigate further, thanks for making the reprex.
Most definitely related, but not addressed by the following bug/fix. Both have to do with indexing of adjacent horizon depths when building polygon fill/outlines. I'll investigate further.
"single-horizon" glitch:
library(aqp)
x <- data.frame(
id = 'A',
top = 0,
bottom = 25,
clay = 15,
stringsAsFactors = FALSE
)
depths(x) <- id ~ top + bottom
plotSPC(x, color = 'clay')
fixed in 621df647d2af6dd3231f810a45d5e414bebd63b9
More useful "data" in the http://ncss-tech.github.io/AQP/aqp/dealing-with-bad-data.html tutorial. This is likely due to the use of pmin
and pmax
in the presence of NA.
Not a good example (and not fixing), severe horizon logic errors:
y1 y0
[1,] 0 5
[2,] 5 12
[3,] 12 21
[4,] 21 47
[5,] 47 71
[6,] 71 109
[7,] 109 131
[8,] 131 172
[9,] 135 150
[10,] 172 210
library(aqp)
library(soilDB)
# pedons indexed by "pedlabsampnum" ID
pls <- c("04N0610", "04N0611", "04N0612", "04N0613")
# vectorization = implicit iteration
res <- fetchKSSL(pedlabsampnum = pls, returnMorphologicData = TRUE, simplifyColors = TRUE)
# check: OK
str(res, 2)
# extract SPC
pedons <- res$SPC
# check: looks good
plotSPC(pedons, color='estimated_ph_h2o', name='hzn_desgn')
# note that `32427` contains overlapOrGap
checkHzDepthLogic(pedons)
Another example. 2/3 fixes are in place and now part of #199. Still need a reasonable solution to the missing "top" boundary in the presence of NA.
library(aqp)
data(sp4)
depths(sp4) <- id ~ top + bottom
par(mar = c(0, 0, 0, 0))
plotSPC(sp4, width = 0.3)
# copy to break
x <- sp4
## legal (deepest) horizons to repair:
# introduce NA
x$bottom[4] <- NA
# top == bottom
x$bottom[6] <- x$top[6]
## not legal horizons to repair
x$bottom[12] <- NA
# marked as invalid
checkHzDepthLogic(x)
plotSPC(x, width = 0.3)
Closing this, as errors in graphical output assist with identification of bad data.
Here is a minimal reproducible example of what happens in
plotSPC
if a horizon is missing.NA
depths (missingDepth logic error)