Skip to content

Shallow soils (Leptosol) display a full 120 cm profile instead of truncating at the end of soil #378

Description

@DerekCaelin

In the global (HWSD) soil-ID path, soils that are shallow by definition — e.g. Lithic Leptosol (hard rock within 20 cm) are sometimes displayed with a full 120 cm profile. At others, they correctly show a profile ending in 20cm.

Possibly related: #375

Steps To Reproduce

  1. Create temporary site at: 0.14594, 35.87959
  2. Tap "learn more"
  3. Tap "Lithic Leptosol"
  4. Review properties table
  5. (see issue)

Expected behavior

Display depths ending in 20cm, as in at 8.48144, 36.35144:

Actual behavior

Display depths ending in 120cm, apparently padding out the previous layers:

Additional context

Analysis and Suggestions from DeepSeek

1. HWSD2 source data encodes the end of soil with -7

HWSD2.mdbHWSD2_LAYERS, WRB4 = 'LPli' ("Lithic Leptosol"):

Layer Depth SAND SILT CLAY COARSE
D1 0–20 cm 51 29 20 36
D2–D7 20–200 cm -7 -7 -7 -7

-7 is HWSD2's "no data" sentinel — effectively "no soil in this layer." The
source represents Lithic Leptosol as ~20 cm of real soil.

2. The algorithm does not truncate on that signal

The global path has no bedrock / no-data filtering (the US path does: it
strips bedrock R horizons — us_soil.py:290).

  • max_comp_depth (soil_id/utils.py:528-537) returns the last layer's
    hzdepb_r (= 200 cm for a 7-layer profile), without checking whether deeper
    layers are the -7/no-data sentinel.
  • agg_data_layer (soil_id/utils.py:299-317) then caps the output at
    120 cm
    (final range [1, 10, 20, 50, 70, 100, 120]).

Result: a shallow soil whose HWSD2 rows still list D2–D7 is padded to the
120 cm cap instead of being truncated at 20 cm.

3. The behavior is inconsistent between points

  • Kenya (0.14594, 35.87959): Lithic leptosol → 0–120 cm (bug).
  • Ethiopia (8.48144, 36.35144): Lithic leptosol → 0–20 cm (correct).

Same soil name, different depth. This indicates the truncation is
data-dependent — the production DB (or the ingest step that builds
hwsd2_data) carries the deep -7-style layers for some Leptosol map units
and not others, and the algorithm faithfully echoes whichever it receives.

Likely root cause

The -7 (no-data) layers are treated as real soil throughout
list_soils_globalmax_comp_depthagg_data_layer. The end-of-soil
signal is never read, so shallow profiles get extended to the 120 cm output cap.

Suggested fix

  1. In list_soils_global, drop or flag horizons whose properties are the
    HWSD2 -7 (or NULL) sentinel, so max_comp_depth reflects the true soil
    depth (Leptosol ends at ~20 cm).
  2. Prefer an explicit depth-to-bedrock / "soil ends here" field (this is the
    same missing signal as the bedrock model discussion), instead of inferring
    depth from raw layer rows.
  3. Investigate the ingest step that builds hwsd2_data from HWSD2 — that is
    where -7 rows should be dropped/flagged, and where the Kenya-vs-Ethiopia
    inconsistency originates.

References

  • soil_id/global_soil.pylist_soils_global / horizon assembly (no no-data filtering)
  • soil_id/us_soil.py:290 — US path strips bedrock R horizons (contrast)
  • soil_id/utils.py:528-537max_comp_depth
  • soil_id/utils.py:299-317agg_data_layer (120 cm cap)
  • soil_id/db.py:183-217get_hwsd2_profile_data (raw layer selection)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

  • Status
    Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions