Skip to content

fsm python tute 5 Soil Mapper

Kipling edited this page May 26, 2021 · 2 revisions

Creating Soil Attribute Maps

In this tutorial, we will learn how to use the SoilMapper tool.

The SoilMapper tool uses a range of statistical techniques to extrapolate the data form the pointDatasets (tutorial two) across the paddock grid.

In this tutorial, we will use the elevation and NDVI layers to create detailed clay maps of our paddocks.

First, we need to construct our SoilMapperConfig which has the following inputs:

    attribute: str # soil attribute to map
    splineConfig: SplineConfig # convers all samples to a uniform depth range
    ptfConfig: Optional[PTFConfig] = None # for estimating new attributes
    regressionConfig: Optional[RegressionConfig] = None # uses layers to create modle and estimage valuse across the paddock
    krigConfig: Optional[KrigConfig] = None # uses kriging to interpolate values across the paddock
    mixConfig: Optional[MixConfig] = None # for mixing two layers

And is used like:

from fsm.configs import SoilMapperConfig, SplineConfig, RegressionConfig, KrigConfig

TEST_ATTRIBUTE = "clay"

soil_mapper_config = SoilMapperConfig(
        attribute=TEST_ATTRIBUTE,
        splineConfig=SplineConfig(
            depth_range=(0,20),
            assume_deep_values=True
        ),
        regressionConfig=RegressionConfig(
            attribute = TEST_ATTRIBUTE,
            training_layers=[ELEVATION,NDVI],
            includeLatLong=False,
        ),
        krigConfig=KrigConfig(attribute=TEST_ATTRIBUTE),
    )

We can now run the SoilMapper tool:

from fsm.soilMapper import SoilMapper

soil_mapper = SoilMapper(paddocks)
build_results = soil_mapper.build(soil_mapper_config)

This returns several build results; including: SplineBuildResult - with the valuse at new depth ranges ResidualsBuildResult - The residuals if the regresswion model PaddockBuildResult - with build results RegressionBuildResult KrigingBuildResult RegressKrigMixBuildResult ResidualsKrigMixBuildResult

And create the images:

from fsm.models.gradients import farmSoilMappingGradients

grad = farmSoilMappingGradients.CLAY
graphics_config = GradientConfig(
    attribute=TEST_ATTRIBUTE,
    gradient=grad,
    output_dir="path/to/output/location",
    fit_to_data=True)

gr = GraphicsRenderer(build_results)
gr.build(graphics_config)

Clone this wiki locally