{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://hugomachadorodrigues.github.io/soilKey/schemas/pedon-schema.json",
  "title": "soilKey PedonRecord schema",
  "description": "Canonical structure of a single soilKey PedonRecord. Use this schema to validate JSON-serialised soil profile data before passing to classify_wrb2022 / classify_sibcs / classify_usda.",
  "type": "object",
  "required": [
    "site",
    "horizons"
  ],
  "properties": {
    "site": {
      "type": "object",
      "description": "Site-level metadata (one record per pedon).",
      "required": [
        "id"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "lat": {
          "type": ["number", "null"],
          "minimum": -90,
          "maximum": 90
        },
        "lon": {
          "type": ["number", "null"],
          "minimum": -180,
          "maximum": 180
        },
        "country": {
          "type": ["string", "null"]
        },
        "parent_material": {
          "type": ["string", "null"]
        },
        "date": {
          "type": ["string", "null"],
          "description": "ISO 8601 date or NULL"
        },
        "reference_wrb": {
          "type": ["string", "null"]
        },
        "reference_sibcs": {
          "type": ["string", "null"]
        },
        "reference_usda": {
          "type": ["string", "null"]
        },
        "reference_usda_subgroup": {
          "type": ["string", "null"]
        },
        "reference_usda_grtgroup": {
          "type": ["string", "null"]
        },
        "reference_usda_suborder": {
          "type": ["string", "null"]
        },
        "nasis_diagnostic_features": {
          "type": ["array", "null"],
          "items": {
            "type": "string"
          },
          "description": "NASIS pediagfeatures.featkind vector (one per surveyor-flagged diagnostic)"
        },
        "reference_source": {
          "type": ["string", "null"]
        }
      },
      "additionalProperties": true
    },
    "horizons": {
      "type": "array",
      "description": "Ordered list of horizons, top to bottom.",
      "minItems": 0,
      "items": {
        "type": "object",
        "required": [
          "top_cm",
          "bottom_cm"
        ],
        "properties": {
          "top_cm": {
            "type": ["number", "null"]
          },
          "bottom_cm": {
            "type": ["number", "null"]
          },
          "designation": {
            "type": ["string", "null"]
          },
          "boundary_distinctness": {
            "type": ["string", "null"]
          },
          "boundary_topography": {
            "type": ["string", "null"]
          },
          "munsell_hue_moist": {
            "type": ["string", "null"]
          },
          "munsell_value_moist": {
            "type": ["number", "null"]
          },
          "munsell_chroma_moist": {
            "type": ["number", "null"]
          },
          "munsell_hue_dry": {
            "type": ["string", "null"]
          },
          "munsell_value_dry": {
            "type": ["number", "null"]
          },
          "munsell_chroma_dry": {
            "type": ["number", "null"]
          },
          "structure_grade": {
            "type": ["string", "null"]
          },
          "structure_size": {
            "type": ["string", "null"]
          },
          "structure_type": {
            "type": ["string", "null"]
          },
          "consistence_moist": {
            "type": ["string", "null"]
          },
          "consistence_wet": {
            "type": ["string", "null"]
          },
          "clay_films_amount": {
            "type": ["string", "null"]
          },
          "clay_films_strength": {
            "type": ["string", "null"]
          },
          "coarse_fragments_pct": {
            "type": ["number", "null"]
          },
          "clay_pct": {
            "type": ["number", "null"]
          },
          "silt_pct": {
            "type": ["number", "null"]
          },
          "sand_pct": {
            "type": ["number", "null"]
          },
          "ph_h2o": {
            "type": ["number", "null"]
          },
          "ph_kcl": {
            "type": ["number", "null"]
          },
          "ph_cacl2": {
            "type": ["number", "null"]
          },
          "oc_pct": {
            "type": ["number", "null"]
          },
          "n_total_pct": {
            "type": ["number", "null"]
          },
          "cec_cmol": {
            "type": ["number", "null"]
          },
          "ecec_cmol": {
            "type": ["number", "null"]
          },
          "bs_pct": {
            "type": ["number", "null"]
          },
          "al_sat_pct": {
            "type": ["number", "null"]
          },
          "ca_cmol": {
            "type": ["number", "null"]
          },
          "mg_cmol": {
            "type": ["number", "null"]
          },
          "k_cmol": {
            "type": ["number", "null"]
          },
          "na_cmol": {
            "type": ["number", "null"]
          },
          "al_cmol": {
            "type": ["number", "null"]
          },
          "caco3_pct": {
            "type": ["number", "null"]
          },
          "caso4_pct": {
            "type": ["number", "null"]
          },
          "fe_dcb_pct": {
            "type": ["number", "null"]
          },
          "fe_ox_pct": {
            "type": ["number", "null"]
          },
          "al_ox_pct": {
            "type": ["number", "null"]
          },
          "si_ox_pct": {
            "type": ["number", "null"]
          },
          "bulk_density_g_cm3": {
            "type": ["number", "null"]
          },
          "water_content_33kpa": {
            "type": ["number", "null"]
          },
          "water_content_1500kpa": {
            "type": ["number", "null"]
          },
          "ec_dS_m": {
            "type": ["number", "null"]
          },
          "plinthite_pct": {
            "type": ["number", "null"]
          },
          "redoximorphic_features_pct": {
            "type": ["number", "null"]
          },
          "slickensides": {
            "type": ["string", "null"]
          },
          "artefacts_pct": {
            "type": ["number", "null"]
          },
          "geomembrane_present": {
            "type": ["boolean", "null"]
          },
          "technic_hardmaterial_pct": {
            "type": ["number", "null"]
          },
          "duripan_pct": {
            "type": ["number", "null"]
          },
          "cementation_class": {
            "type": ["string", "null"]
          },
          "p_mehlich3_mg_kg": {
            "type": ["number", "null"]
          },
          "worm_holes_pct": {
            "type": ["number", "null"]
          },
          "water_dispersible_clay_pct": {
            "type": ["number", "null"]
          },
          "sulfidic_s_pct": {
            "type": ["number", "null"]
          },
          "volcanic_glass_pct": {
            "type": ["number", "null"]
          },
          "phosphate_retention_pct": {
            "type": ["number", "null"]
          },
          "artefacts_industrial_pct": {
            "type": ["number", "null"]
          },
          "artefacts_urbic_pct": {
            "type": ["number", "null"]
          },
          "rock_origin": {
            "type": ["string", "null"]
          },
          "permafrost_temp_C": {
            "type": ["number", "null"]
          },
          "cracks_width_cm": {
            "type": ["number", "null"]
          },
          "cracks_depth_cm": {
            "type": ["number", "null"]
          },
          "polygonal_cracks_spacing_cm": {
            "type": ["number", "null"]
          },
          "desert_pavement_pct": {
            "type": ["number", "null"]
          },
          "varnish_pct": {
            "type": ["number", "null"]
          },
          "ventifact_pct": {
            "type": ["number", "null"]
          },
          "vesicular_pores": {
            "type": ["string", "null"]
          },
          "rupture_resistance": {
            "type": ["string", "null"]
          },
          "plasticity": {
            "type": ["string", "null"]
          },
          "al_kcl_cmol": {
            "type": ["number", "null"]
          },
          "layer_origin": {
            "type": ["string", "null"]
          },
          "fiber_content_rubbed_pct": {
            "type": ["number", "null"]
          },
          "fiber_content_unrubbed_pct": {
            "type": ["number", "null"]
          },
          "von_post_index": {
            "type": ["integer", "null"]
          },
          "cole_value": {
            "type": ["number", "null"]
          },
          "sio2_sulfuric_pct": {
            "type": ["number", "null"]
          },
          "al2o3_sulfuric_pct": {
            "type": ["number", "null"]
          },
          "fe2o3_sulfuric_pct": {
            "type": ["number", "null"]
          },
          "sand_mica_pct": {
            "type": ["number", "null"]
          },
          "sand_amphibole_pct": {
            "type": ["number", "null"]
          },
          "sand_feldspar_pct": {
            "type": ["number", "null"]
          },
          "sand_mineralogy": {
            "type": ["string", "null"]
          },
          "woody_fragments_pct": {
            "type": ["number", "null"]
          },
          "surface_crust_type": {
            "type": ["string", "null"]
          },
          "bioturbation_density": {
            "type": ["string", "null"]
          },
          "cordic_horizon": {
            "type": ["boolean", "null"]
          },
          "microrelief_form": {
            "type": ["string", "null"]
          },
          "weathering_stage": {
            "type": ["string", "null"]
          },
          "salt_crust_pattern": {
            "type": ["string", "null"]
          },
          "contamination_type": {
            "type": ["string", "null"]
          },
          "stratification_pattern": {
            "type": ["string", "null"]
          },
          "aeolian_morphology": {
            "type": ["string", "null"]
          },
          "mottle_morphology": {
            "type": ["string", "null"]
          },
          "surface_puff_layer": {
            "type": ["boolean", "null"]
          },
          "thixotropic_index": {
            "type": ["number", "null"]
          },
          "saprolite_pct": {
            "type": ["number", "null"]
          },
          "water_regime_pattern": {
            "type": ["string", "null"]
          }
        },
        "additionalProperties": false
      }
    },
    "provenance": {
      "type": ["array", "null"],
      "description": "Per-attribute provenance log; one row per measurement.",
      "items": {
        "type": "object",
        "required": [
          "attribute",
          "source"
        ],
        "properties": {
          "attribute": {
            "type": "string"
          },
          "value": {
            "type": ["number", "string", "null"]
          },
          "source": {
            "type": "string",
            "enum": [
              "measured",
              "predicted_spectra",
              "extracted_vlm",
              "inferred_prior",
              "user_assumed"
            ]
          },
          "confidence": {
            "type": ["number", "null"],
            "minimum": 0,
            "maximum": 1
          },
          "notes": {
            "type": ["string", "null"]
          }
        }
      }
    }
  },
  "additionalProperties": true
}
