Skip to content

[POC] classif step 2: slope classificatio #693

Open
@adebardo

Description

@adebardo

Context

Following the implementation of the ClassificationLayer base class, we need to develop the SlopeClassificationLayer. This class will handle slope-based classification of a DEM, where it calculates the slope and classifies DEM pixels into predefined slope ranges (e.g., [0, 5, 10, 25, 50, 100] degrees).

The SlopeClassificationLayer will inherit from the ClassificationLayer and will implement slope-specific classification logic.

Code

In the same file (classification.py) as the ClassificationLayer base class, add the SlopeClassificationLayer to define slope classification functionality.

  1. __init__() method:
    • Extend the initialization from the ClassificationLayer.
    • Include an additional attribute specific to slope classification:
      • ranges: A list of slope ranges used to classify the DEM pixels into different slope categories.
  2. apply_classification() method:
    • Use the DEM.slope() method to compute the slope.
    • Classify the pixels into the defined slope ranges:
      • For each class, create a mask representing the slope range.
    • Store the masks in the classification attribute, which is a geoutils.Mask 3D object, where the first dimension represents the class, and the two others represent the mask values.
    • Store the class names and their associated bands under the class_names attribute (a dict[str, int] object). Example:
self.class_names = {"slope0_5": 0, "slope5_10": 1, ...}

Tests

  • Write unit tests for the SlopeClassificationLayer class in a new test_classification.py file.
  • The unit tests should:
    1. Verify that the layer initializes properly with the provided configuration.
    2. Ensure that the classification logic works as expected.
    3. Confirm that statistics are computed as expected.
    4. Validate that the results are saved correctly.

Documentation

Include the necessary information in the documentation for the user.
Example: clarify the list of ranges and how to use it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions