xdem icon indicating copy to clipboard operation
xdem copied to clipboard

[POC]: processing terrain attributes in CLI

Open adebardo opened this issue 1 year ago • 2 comments

Context

The purpose of this ticket is to implement the calculation of terrain attributes from the CLI. All methods with defaults values

**** method degrees azimuth altitude z_factor window_size
slope Horn True
aspect Horn True
hillshade Horn 315.0 45.0 1.0
curvature
planform curvature
profile_curvature x
maximum_curvature x
topographic_position_index 3
roughness 3

Configuration

[attributes]

[attributes.slope]
dem = "path/to/dem"
parameters = {"method" ="Horn", "degrees" = true}

Code

  • [ ] Add a function to verify all the possible combination in the class as the coreg step, Make the attribute parameters optional and replace them with default values.

  • [ ] As with all coregistration methods, add the dictionary for terrain attributes.

    terrain_methods = {  
        "slope": DEM.slope,  
        "hillshade": DEM.hillshade,
    }

We suggest storing this type of dictionary directly in the associated classes from now on.

  • [ ] Loop in the run over the list and save the outputs.

# open the DEM here 

dem_to_analize = dem.DEM("path")

for key, _ in cfg["attributes"]: 
  terrain_attributes_function = terrain_methods.get("key")
  terrain_attributes_parameter = config["attributes"]["key"]
  terrain_attr = dem_to_analize.terrain_attributes_function(**terrain_attributes_parameter)
  terrain_attr.save(attr + ".tif")

Tests

  • [ ] Verify that the outputs are correctly generated.
  • [ ] Also check the ground truth verification.

Documentation

  • [ ] Update the documentation referring to the CLI.

Estimation

4d

adebardo avatar Aug 23 '24 13:08 adebardo

Seems ok to me. Just a few comments:

  • I don't think you need the argument resolution. It's only needed when the input is not a Raster/DEM object, but a numpy array. This will not be the case here.
  • Is it an option to pass all (optional) arguments for the terrain attribute calculation as a dictionary? E.g. {"method"="Horn", "degrees"="true"}?

adehecq avatar Sep 17 '24 13:09 adehecq

Hello, I removed the resolution, and yes, passing all this parameters will be optional and replaced by a default value if needed. I complete the tickets for this to be clear

adebardo avatar Sep 18 '24 12:09 adebardo