Classification layers

Classification layers are a way to classify the DEM pixels in classes according to different criteria in order to compute specific statistics according to each class.

Four types of classification layers exist:

The global classification is the default classification and is always computed. This layer has a single class where all valid pixels are considered. If no classification layers are specified in the input configuration, only the global classification will be considered.

The modes

As shown in previous section, demcompare will classify stats according to classification layers and classification layer masks must be superimposable to one DEM, meaning that the classification mask and its support DEM must have the same size and resolution.

Whenever a classification layer is given for both DEMs (say one has two DEMs with associated segmentation maps) then it can be possible to observe the metrics for pixels whose classification (segmentation for example) is the same between both DEM or not. These observations are available through what we call mode. Demcompare supports:

Within this mode all valid pixels are considered. It means nan values but also outliers (if remove_outliers was set to "True") and masked ones are discarded.

Note that the nan values can be originated from the altitude differences image and / or the exogenous classification layers themselves (ie. if the input segmentation has NaN values, the corresponding pixels will not be considered for the statistics computation of this classification layer).

In the following schema we can see a scenario where two different segmentation layers and a slope layer are created. Both segmentation layers having a single support and the slope layer having two supports.

  • Segmentation_0 has only ref support, hence the statistics are computed considering the ref segmentation_0_mask.

  • Segmentation_1 has only sec support, hence the statistics are computed considering the sec segmentation_1_mask.

  • Slope_0 has both ref and support, hence the statistics are computed considering:

    • the ref slope_0_mask for the standard mode

    • the intersection between the ref slope_0_mask and the sec slope_0_mask for the intersection and exclusion modes.

../../_images/stats_support_schema.png

Fig. 10 Statistics schema with intersection and exclusion modes.

Metric selection

The metrics to be computed may be specified at different levels on the statistics configuration:

  • Global level: those metrics will be computed for all classification layers

  • Classification layer level: those metrics will be computed specifically for the given classification layer

For instance, with the following configuration we could compute the mean, ratio_above_threshold metrics on all layers, whilst nmad metric would be computed only for the Slope0 layer.

"statistics": {
  "alti-diff": {
      "classification_layers": {
          "Status": {
              "type": "segmentation",
              "classes": {
                  "valid": [0],
                  "KO": [1],
                  "Land": [2],
                  "NoData": [3],
                  "Outside_detector": [4],
              },
          },
          "Slope0": {
              "type": "slope",
              "ranges": [0, 10, 25, 50, 90],
              "metrics": ["nmad"],
          },
          "Fusion0": {
              "type": "fusion",
              "sec": ["Slope0", "Status"]
          },
      }
  },
  "metrics": [
      "mean",
      {"ratio_above_threshold": {"elevation_threshold": [1, 2, 3]}},
  ],
 }