Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[POC] classif step 2: slope classificatio #693

Open
adebardo opened this issue Mar 3, 2025 · 0 comments
Open

[POC] classif step 2: slope classificatio #693

adebardo opened this issue Mar 3, 2025 · 0 comments
Labels
[POC] Conception To review Tickets needs approval about it conception

Comments

@adebardo
Copy link
Contributor

adebardo commented Mar 3, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[POC] Conception To review Tickets needs approval about it conception
Projects
None yet
Development

No branches or pull requests

1 participant