Skip to content

Commit a5800c0

Browse files
authored
Merge pull request #87 from ncss-tech/osd-multiline1
fix: OSD: concatenate multiline typical pedon horizons
2 parents 2a3d330 + c3a4f02 commit a5800c0

File tree

503 files changed

+12431
-12420
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

503 files changed

+12431
-12420
lines changed

R/parseOSD_functions.R

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -357,10 +357,21 @@
357357
hz.idx <- hz.idx[-first.line.flag]
358358
}
359359

360-
check.multiline <- diff(hz.idx) > 1
361-
if (any(check.multiline)) {
360+
check.multiline <- diff(hz.idx)
361+
if (any(check.multiline > 1)) {
362362
# multiline typical pedon horizon formatting (needs fix)
363-
logmsg(logfile, paste0("CHECK MULTILINE TYPICAL PEDON: ", filename, " [number of multilines=", sum(check.multiline), "]"))
363+
logmsg(logfile, paste0("CHECK MULTILINE TYPICAL PEDON: ", filename, " [number of multilines=", sum(check.multiline > 1), "]"))
364+
}
365+
366+
if (length(hz.idx) > 0 ) {
367+
# concatenate multiline entries in typical pedon
368+
multiline.rle <- list(lengths = c(check.multiline, 1),
369+
values = hz.idx)
370+
class(multiline.rle) <- "rle"
371+
grp <- inverse.rle(multiline.rle)
372+
tpclean <- sapply(split(tp[min(grp):max(grp)], grp), paste, collapse = " ")
373+
} else {
374+
tpclean <- tp[0]
364375
}
365376

366377
# init empty lists to store hz data and colors
@@ -370,8 +381,8 @@
370381
narrative.data <- list()
371382

372383
# iterate over identified horizons, extracting hz parts
373-
for (i in seq_along(hz.idx)) {
374-
this.chunk <- tp[hz.idx[i]]
384+
for (i in seq_along(tpclean)) {
385+
this.chunk <- tpclean[i]
375386

376387
# parse hz designations and depths, keep first match
377388
# first try to find horizons with top AND bottom depths
@@ -408,26 +419,26 @@
408419
if (!is.na(h[1]) && grepl("[OABCDELMRVWbcxw]", h[1])) {
409420
# save hz data to list
410421
hz.data[[i]] <- h
411-
422+
412423
# save narrative to list
413424
narrative.data[[i]] <- this.chunk
414-
425+
415426
## TODO: test this!
416427
# parse ALL colors, result is a multi-row matrix, 5th column is moisture state
417428
colors <- stringi::stri_match_all(this.chunk, regex = color.rule)[[1]]
418-
429+
419430
# replace missing moisture state with (parsed) default value
420431
colors[, 5][which(colors[, 5] == '')] <- default.moisture.state
421-
432+
422433
# extract dry|moist colors, note that there may be >1 color per state
423434
dc <- colors[which(colors[, 5] == 'dry'), 1:4, drop = FALSE]
424435
mc <- colors[which(colors[, 5] == 'moist'), 1:4, drop = FALSE]
425-
436+
426437
# there there was at least 1 match, keep the first 1
427438
if (nrow(dc) > 0) {
428439
dry.colors[[i]] <- dc[1, ]
429440
} else dry.colors[[i]] <- matrix(rep(NA, times = 4), nrow = 1)
430-
441+
431442
if (nrow(mc) > 0)
432443
moist.colors[[i]] <- mc[1, ]
433444
else moist.colors[[i]] <- matrix(rep(NA, times = 4), nrow = 1)
@@ -437,7 +448,7 @@
437448
dry.colors[[i]] <- NULL
438449
moist.colors[[i]] <- NULL
439450
}
440-
451+
441452
}
442453

443454
# test for no parsed data, must be some funky formatting...

inst/extdata/OSD-error-reporting/RO/bozeman-hz.csv

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"BENSLEY","Bw3",79,114,"l0YR","6","2","l0YR","4","2"
5050
"BENSLEY","BC",114,160,"l0YR","6","3","l0YR","4","3"
5151
"BENTILLA","Oi",5,0,NA,NA,NA,NA,NA,NA
52-
"BICKETT","2Bkgl",28,61,NA,NA,NA,"2.5Y","6","1"
52+
"BICKETT","2Bkgl",28,61,"2.5Y","7","1","2.5Y","6","1"
5353
"BIRDSVIEW","A",0,13,"l0YR","5","4","l0YR","3","3"
5454
"BIRDSVIEW","O",10,0,NA,NA,NA,NA,NA,NA
5555
"BIRDSVIEW","Bwl",13,76,NA,NA,NA,"l0YR","4","4"
@@ -178,7 +178,7 @@
178178
"DOMELL","Bw1",28,58,"l0YR","6","4","l0YR","3","3"
179179
"DOMELL","Bw2",58,94,"l0YR","7","4","l0YR","4","4"
180180
"EASTPINE","Oi",3,0,NA,NA,NA,NA,NA,NA
181-
"EDFRO","Bsl",18,28,NA,NA,NA,"7.5YR","4","6"
181+
"EDFRO","Bsl",18,28,"7.5YR","5","8","7.5YR","4","6"
182182
"EDGEWICK","Bwl",20,25,"2.5Y","7","2","2.5Y","4","4"
183183
"EDSON","Oi",5,0,NA,NA,NA,NA,NA,NA
184184
"EGYPTCREEK","Oi",3,0,NA,NA,NA,NA,NA,NA
@@ -253,7 +253,7 @@
253253
"HOOTER","Oe",5,0,NA,NA,NA,NA,NA,NA
254254
"HOOTER","Oi",8,5,NA,NA,NA,NA,NA,NA
255255
"HOPBURN","Oi",1,0,NA,NA,NA,NA,NA,NA
256-
"HOVDE","A",0,23,NA,NA,NA,"l0YR","3","2"
256+
"HOVDE","A",0,23,"2.5Y","6","2","l0YR","3","2"
257257
"HOVDE","Oi",3,0,NA,NA,NA,NA,NA,NA
258258
"HOVDE","2C2",33,74,"l0YR","5","3","l0YR","4","3"
259259
"HOVDE","2C4",99,152,"l0YR","4","2","l0YR","3","2"
@@ -667,11 +667,11 @@
667667
"WARRENTON","O",8,0,NA,NA,NA,"N","2",NA
668668
"WASHOUGAL","O1",3,0,NA,NA,NA,NA,NA,NA
669669
"WEDGEMONT","Bsl",5,51,"10YR","7","3","10YR","5","3"
670-
"WELCOME","E",0,5,NA,NA,NA,"l0YR","4","3"
670+
"WELCOME","E",0,5,"l0YR","7","2","l0YR","4","3"
671671
"WELCOME","Oa",5,0,NA,NA,NA,NA,NA,NA
672-
"WELCOME","Bs1",5,15,NA,NA,NA,"l0YR","3","4"
672+
"WELCOME","Bs1",5,15,"l0YR","6","4","l0YR","3","4"
673673
"WELCOME","Oi",8,5,NA,NA,NA,NA,NA,NA
674-
"WELCOME","Bs2",15,48,NA,NA,NA,"l0YR","3","6"
674+
"WELCOME","Bs2",15,48,"l0YR","7","4","l0YR","3","6"
675675
"WELLSBENCH","Btl",15,36,"10YR","4","2","10YR","3","3"
676676
"WESSEL","O1 and O2",5,0,NA,NA,NA,NA,NA,NA
677677
"WHETSTONE","O2",5,0,NA,NA,NA,NA,NA,NA

inst/extdata/OSD-error-reporting/log.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@
257257
UT 219 11
258258
VA 30 0
259259
VT 8 0
260-
WA 249 39
260+
WA 248 40
261261
WI 8 0
262262
WV 4 0
263263
WY 212 1

inst/extdata/OSD-error-reporting/state/ID-hz.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"id","name","top","bottom","dry_hue","dry_value","dry_chroma","moist_hue","moist_value","moist_chroma"
2-
"BICKETT","2Bkgl",28,61,NA,NA,NA,"2.5Y","6","1"
2+
"BICKETT","2Bkgl",28,61,"2.5Y","7","1","2.5Y","6","1"
33
"BUTTECREEK","Oe",5,0,NA,NA,NA,NA,NA,NA
44
"CHICANE","A12",13,36,"lOYR","3","2","lOYR","2","1"
55
"CHICANE","B2",36,53,"lOYR","4","2","lOYR","3","1"

inst/extdata/OSD-error-reporting/state/WA-hz.csv

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
"DOMELL","A2",13,28,"l0YR","5","3","l0YR","3","3"
115115
"DOMELL","Bw1",28,58,"l0YR","6","4","l0YR","3","3"
116116
"DOMELL","Bw2",58,94,"l0YR","7","4","l0YR","4","4"
117-
"EDFRO","Bsl",18,28,NA,NA,NA,"7.5YR","4","6"
117+
"EDFRO","Bsl",18,28,"7.5YR","5","8","7.5YR","4","6"
118118
"EDGEWICK","Bwl",20,25,"2.5Y","7","2","2.5Y","4","4"
119119
"ELWELL","O2",3,0,NA,NA,NA,NA,NA,NA
120120
"ELWELL","O1",5,3,NA,NA,NA,NA,NA,NA
@@ -150,7 +150,7 @@
150150
"HOFFSTADT","Oe",5,0,NA,NA,NA,NA,NA,NA
151151
"HOODSPORT","Oe",3,0,NA,NA,NA,"5YR","2","1"
152152
"HOODSPORT","Oi",6,3,NA,NA,NA,NA,NA,NA
153-
"HOVDE","A",0,23,NA,NA,NA,"l0YR","3","2"
153+
"HOVDE","A",0,23,"2.5Y","6","2","l0YR","3","2"
154154
"HOVDE","Oi",3,0,NA,NA,NA,NA,NA,NA
155155
"HOVDE","2C2",33,74,"l0YR","5","3","l0YR","4","3"
156156
"HOVDE","2C4",99,152,"l0YR","4","2","l0YR","3","2"
@@ -424,11 +424,11 @@
424424
"WALVILLE","Al2",30,43,"7.5YR","5","4","7.5YR","3","4"
425425
"WASHOUGAL","O1",3,0,NA,NA,NA,NA,NA,NA
426426
"WEDGEMONT","Bsl",5,51,"10YR","7","3","10YR","5","3"
427-
"WELCOME","E",0,5,NA,NA,NA,"l0YR","4","3"
427+
"WELCOME","E",0,5,"l0YR","7","2","l0YR","4","3"
428428
"WELCOME","Oa",5,0,NA,NA,NA,NA,NA,NA
429-
"WELCOME","Bs1",5,15,NA,NA,NA,"l0YR","3","4"
429+
"WELCOME","Bs1",5,15,"l0YR","6","4","l0YR","3","4"
430430
"WELCOME","Oi",8,5,NA,NA,NA,NA,NA,NA
431-
"WELCOME","Bs2",15,48,NA,NA,NA,"l0YR","3","6"
431+
"WELCOME","Bs2",15,48,"l0YR","7","4","l0YR","3","6"
432432
"WILKESON","Al",0,10,"l0YR","5","2","l0YR","3","2"
433433
"WILKESON","A2",10,25,"l0YR","5","3","l0YR","3","3"
434434
"WILKESON","BA",25,46,"l0YR","5","3","l0YR","4","3"

inst/extdata/OSD/A/ACKWATER.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,11 @@
134134
"coherence": "NA",
135135
"cf_class": "NA",
136136
"pH": "NA",
137-
"pH_class": "NA",
137+
"pH_class": "very strongly acid",
138138
"eff_class": "NA",
139-
"distinctness": "NA",
140-
"topography": "NA",
141-
"narrative": "Bt2--9 to 16 inches; yellowish brown (lOYR 5/8) silty clay loam; moderate medium subangular blocky structure; firm, sticky, plastic; few fine roots; few very fine pores; common prominent clay films on"
139+
"distinctness": "gradual",
140+
"topography": "smooth",
141+
"narrative": "Bt2--9 to 16 inches; yellowish brown (lOYR 5/8) silty clay loam; moderate medium subangular blocky structure; firm, sticky, plastic; few fine roots; few very fine pores; common prominent clay films on faces of peds; very strongly acid; gradual smooth boundary."
142142
},
143143
{
144144
"name": "Bt3",
@@ -157,11 +157,11 @@
157157
"coherence": "NA",
158158
"cf_class": "NA",
159159
"pH": "NA",
160-
"pH_class": "NA",
160+
"pH_class": "very strongly acid",
161161
"eff_class": "NA",
162-
"distinctness": "NA",
163-
"topography": "NA",
164-
"narrative": "Bt3--16 to 28 inches; strong brown (7.5YR 5/8) silty clay; many coarse distinct light gray (lOYR 7/1) iron depletions and common medium prominent red 2.5YR 4/8) masses of iron accumulation; weak coarse prismatic structure parting to moderate medium subangular blocky; firm, sticky, plastic; few fine roots; few very fine pores; common prominent clay films on faces of peds;"
162+
"distinctness": "gradual",
163+
"topography": "wavy",
164+
"narrative": "Bt3--16 to 28 inches; strong brown (7.5YR 5/8) silty clay; many coarse distinct light gray (lOYR 7/1) iron depletions and common medium prominent red 2.5YR 4/8) masses of iron accumulation; weak coarse prismatic structure parting to moderate medium subangular blocky; firm, sticky, plastic; few fine roots; few very fine pores; common prominent clay films on faces of peds; very strongly acid; gradual wavy boundary."
165165
},
166166
{
167167
"name": "Bt4",
@@ -180,11 +180,11 @@
180180
"coherence": "NA",
181181
"cf_class": "NA",
182182
"pH": "NA",
183-
"pH_class": "NA",
183+
"pH_class": "very strongly acid",
184184
"eff_class": "NA",
185-
"distinctness": "NA",
186-
"topography": "NA",
187-
"narrative": "Bt4--28 to 52 inches; mottled strong brown (7.5YR 5/8), light gray (lOYR 7/1), red (2.5YR 4/8), and brownish yellow (lOYR 6/8) silty clay; moderate coarse prismatic structure parting to moderate very thick platy parting to moderate medium angular blocky; firm, sticky, plastic; few very fine roots along faces of peds; common prominent clay"
185+
"distinctness": "gradual",
186+
"topography": "smooth",
187+
"narrative": "Bt4--28 to 52 inches; mottled strong brown (7.5YR 5/8), light gray (lOYR 7/1), red (2.5YR 4/8), and brownish yellow (lOYR 6/8) silty clay; moderate coarse prismatic structure parting to moderate very thick platy parting to moderate medium angular blocky; firm, sticky, plastic; few very fine roots along faces of peds; common prominent clay films on faces of peds; very strongly acid; gradual smooth boundary."
188188
},
189189
{
190190
"name": "Btg",

inst/extdata/OSD/A/ACUNA.json

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,17 @@
8282
"moist_value": 3,
8383
"moist_chroma": 2,
8484
"texture_class": "silty clay",
85-
"structure": "NA",
86-
"dry_rupture": "NA",
87-
"moist_rupture": "NA",
85+
"structure": "moderate medium subangular blocky",
86+
"dry_rupture": "hard",
87+
"moist_rupture": "friable",
8888
"coherence": "NA",
8989
"cf_class": "NA",
9090
"pH": "NA",
91-
"pH_class": "NA",
91+
"pH_class": "moderately alkaline",
9292
"eff_class": "NA",
93-
"distinctness": "NA",
94-
"topography": "NA",
95-
"narrative": "A1--0 to 18 inches; dark grayish brown (10YR 4/2) silty clay, very dark grayish brown (10YR 3/2) moist; the upper 2 inches is grayish brown (10YR 5/2); moderate medium subangular blocky"
93+
"distinctness": "clear",
94+
"topography": "wavy",
95+
"narrative": "A1--0 to 18 inches; dark grayish brown (10YR 4/2) silty clay, very dark grayish brown (10YR 3/2) moist; the upper 2 inches is grayish brown (10YR 5/2); moderate medium subangular blocky structure parting to moderate medium granular; slightly hard, friable; common fine and medium roots; common fine pores; few fine threads and films of calcium carbonate; few fine calcium carbonate concretions less than 2 mm across; calcareous; moderately alkaline; clear wavy boundary. (10 to 20 inches thick)"
9696
},
9797
{
9898
"name": "B21",
@@ -101,21 +101,21 @@
101101
"dry_hue": "7.5YR",
102102
"dry_value": 5,
103103
"dry_chroma": 4,
104-
"moist_hue": "NA",
105-
"moist_value": "NA",
106-
"moist_chroma": "NA",
104+
"moist_hue": "7.5YR",
105+
"moist_value": 4,
106+
"moist_chroma": 4,
107107
"texture_class": "clay",
108-
"structure": "NA",
109-
"dry_rupture": "NA",
110-
"moist_rupture": "NA",
108+
"structure": "moderate medium subangular blocky",
109+
"dry_rupture": "hard",
110+
"moist_rupture": "friable",
111111
"coherence": "NA",
112112
"cf_class": "NA",
113113
"pH": "NA",
114-
"pH_class": "NA",
114+
"pH_class": "moderately alkaline",
115115
"eff_class": "NA",
116-
"distinctness": "NA",
117-
"topography": "NA",
118-
"narrative": "B21--18 to 30 inches; brown (7.5YR 5/4) clay, dark brown"
116+
"distinctness": "abrupt",
117+
"topography": "wavy",
118+
"narrative": "B21--18 to 30 inches; brown (7.5YR 5/4) clay, dark brown (7.5YR 4/4) moist; moderate medium subangular blocky structure parting to moderate medium granular; hard, friable; few fine roots; common very fine pores; few films and threads of calcium carbonate; few thin discontinuous clay films on vertical ped surfaces; calcareous; moderately alkaline; abrupt wavy boundary. (6 to 28 inches thick)"
119119
},
120120
{
121121
"name": "B22ca",
@@ -124,21 +124,21 @@
124124
"dry_hue": "7.5R",
125125
"dry_value": 7,
126126
"dry_chroma": 4,
127-
"moist_hue": "NA",
128-
"moist_value": "NA",
129-
"moist_chroma": "NA",
127+
"moist_hue": "7.5YR",
128+
"moist_value": 5,
129+
"moist_chroma": 4,
130130
"texture_class": "silty clay",
131-
"structure": "NA",
132-
"dry_rupture": "NA",
133-
"moist_rupture": "NA",
131+
"structure": "weak fine subangular blocky",
132+
"dry_rupture": "hard",
133+
"moist_rupture": "friable",
134134
"coherence": "NA",
135135
"cf_class": "NA",
136136
"pH": "NA",
137-
"pH_class": "NA",
137+
"pH_class": "moderately alkaline",
138138
"eff_class": "NA",
139-
"distinctness": "NA",
140-
"topography": "NA",
141-
"narrative": "B22ca--30 to 38 inches; pink (7.5R 7/4) silty clay, brown"
139+
"distinctness": "clear",
140+
"topography": "wavy",
141+
"narrative": "B22ca--30 to 38 inches; pink (7.5R 7/4) silty clay, brown (7.5YR 5/4) moist; weak fine subangular blocky structure; slightly hard; friable; many very fine pores; 15 percent by volume of threads, films, and concretions 2 mm to 2 cm across of calcium carbonate; calcareous; moderately alkaline; clear wavy boundary. (8 to 28 inches thick)"
142142
},
143143
{
144144
"name": "B23ca",
@@ -152,16 +152,16 @@
152152
"moist_chroma": 6,
153153
"texture_class": "silty clay",
154154
"structure": "weak fine subangular blocky",
155-
"dry_rupture": "hard",
155+
"dry_rupture": "soft",
156156
"moist_rupture": "friable",
157157
"coherence": "NA",
158158
"cf_class": "NA",
159159
"pH": "NA",
160-
"pH_class": "NA",
160+
"pH_class": "moderately alkaline",
161161
"eff_class": "NA",
162-
"distinctness": "NA",
163-
"topography": "NA",
164-
"narrative": "B23ca--38 to 60 inches; pink (7.5YR 8/4) silty clay, reddish yellow (7.5YR 7/6) moist; weak fine subangular blocky structure; slightly hard, friable; common very fine pores; 8 percent by"
162+
"distinctness": "gradual",
163+
"topography": "wavy",
164+
"narrative": "B23ca--38 to 60 inches; pink (7.5YR 8/4) silty clay, reddish yellow (7.5YR 7/6) moist; weak fine subangular blocky structure; slightly hard, friable; common very fine pores; 8 percent by volume of threads, films and soft masses of 2 mm to 2 cm across of calcium carbonate, calcareous; moderately alkaline; gradual wavy boundary. (10 to 25 inches thick)"
165165
},
166166
{
167167
"name": "B24ca",

0 commit comments

Comments
 (0)