Fuzzy aggregation of two raster layers with FuzzyAttributes V2

After the two articles on converting a raster to fuzzy values:

  • Transforming a raster into fuzzy values with FuzzyAttributes V2
  • Converting a class raster to a fuzzy raster in QGIS

We will sees dans cet article comment agréger deux rasters flous en prenant en compte la subjectivité de l’utilisateur.



Settings window

In the FuzzyAttributes plugin menu, select “Raster Aggregation.”

“Raster 1” and “Raster 2” fields

The “Raster” fields display the list of loaded layers, limited to raster layers. The current version only works on single-band rasters.


Output raster name and Output folder

These two fields allow you to define the location and name of the resulting raster. The default format for this raster is .tif.


Spatial extent

This option allows you to manage the spatial extent of the resulting layer.

The intersection option keeps the extent corresponding to the overlap of the two input layers in the result layer. For each intersection, the result attribute is calculated using the function defined below. However, this means that if a layer has no data for a given area, that area is ignored in the resulting layer. In a process involving several aggregations of different extents, the resulting layer will be significantly reduced. Furthermore, the absence of data for a given area will prevent it from being “caught up” in subsequent aggregations.

The union option keeps the extent corresponding to the two input layers in the result layer. For each overlapping area, the result attribute is calculated using the function defined below. For areas where one of the two layers has no data, the result attribute is calculated using the function defined below, considering that the value of the missing layer is “very poor.” In a process involving several aggregations of different extents, the resulting layer will not be truncated at all. Furthermore, the absence of data in an area will not prevent it from being “caught up” in subsequent aggregations.


Resampling method


Context: why are we talking about resampling?

When we want to aggregate two rasters (for example, to calculate the average, minimum, sum, or fuzzy combination), QGIS must ensure that the two are compatible:

  • same pixel size (resolution),
  • same geographic coverage,
  • same projection (CRS),
  • same grid alignment.

In reality, however, rasters often come from different sources:

  • one raster with a resolution of 10 m,
  • another with a resolution of 30 m,
  • and a third with a slightly different offset.

QGIS must then resample one (or both) rasters to make them match before aggregation.


What is resampling?

Resampling consists of recalculating the pixel values of one raster based on another grid.

The plugin automatically selects the highest resolution of the two input rasters.


The main resampling methods

In QGIS (and GDAL), here are the main methods:

Method Recommended data type Description
Nearest Neighbor Categorical (classes, masks, binary blur, etc.) Selects the value of the nearest source pixel. Preserves classes, fast, but sometimes creates staircase effects.
Bilinear Continuous (elevation, temperature, probability, etc.) Calculates a weighted average of the 4 neighboring pixels. Smoother result, but slightly modifies the values.
Cubic (bicubic) Continuous, analysis data Finer interpolation over 16 neighboring pixels. Smoother, but slower.
Average Aggregation to coarser resolution Calculates the average of all source pixels that fall within the new cell. Ideal for going from 10 m → 100 m.
Lanczos Continuous images, orthophotos, DTM, NDVI The Lanczos method is an interpolation based on a truncated sinc function. Very sharp, little blurring, little distortion.


Définir la fonction d’agrégation

Vous devez cocher une réponse pour chacune des trois questions.

Si vous considérez que l’inversion des deux critères modifie vos réponses (asymétrie des critères), cochez la case Vérifier la symétrie. Une quatrième question vosu permettra de rentrer votre réponse.


Define the aggregation function

L’attribut alt de cette image est vide, son nom de fichier est fzyaggr_fonction-1024x399.jpg.

You must select an answer for each of the three questions.

If you consider that reversing the two criteria changes your answers (asymmetry of criteria), check the Verify symmetry box. A fourth question will allow you to enter your answer.

L’attribut alt de cette image est vide, son nom de fichier est fzyaggr_fonction_assym-1024x545.jpg.


Procedure for determining the aggregation operation.

When aggregating two objectives, there is a simple procedure for determining the type of operation to be performed. It consists of presenting the decision-maker with three typical situations and asking them to evaluate them. Based on the three responses given, a catalog of functions is searched to find the one that best matches the decision-maker’s wishes.

The three typical situations (S1, S2, S3) are chosen according to two criteria (C1, C2) so that:

  • – S1 is incompatible (grade E or 0) with C1, but fully compatible (grade A or 1) with C2;
  • – S2 is moderately compatible (grade C or 0.5) with both objectives C1 and C2;
  • – S3 is moderately compatible (grade C or 0.5) with C1 and fully compatible (grade A or 1) with C2.

This gives us three answers (R1, R2, R3), from which we seek the aggregation operation.

The three types of functions implemented

Two situations are to be studied:

  • a) two criteria of equal importance;
  • b) two criteria of unequal importance

Criteria of equal importance (symmetrical)

Two criteria are of equal importance if the aggregation function is symmetrical, i.e. if the answer to the three evaluation questions is the same when the order of the criteria is reversed.

In this case, based on the three answers (A1, A2, A3), the aggregation operation is sought in the following table:


Adjustment method for asymmetric criteria

When a user defines a fuzzy aggregation function based on non-symmetrical responses (e.g., certain criteria deemed more important than others, or combinations deemed atypical), the plugin uses an approximation method to automatically generate a custom aggregation function.

The generate_asymmetric_function(code) function:

  1. Key points defined by the user

    • The user chooses four aggregation values corresponding to reference situations:

      • (1, 0): criterion A completely true, criterion B completely false->vA1B0
      • (0.5, 0.5): both criteria average->vA05B05
      • (0.5, 1): criterion A average, criterion B completely true->vA05B1
      • (0, 1): criterion A completely false, criterion B completely true->vA0B1

    • These values are encoded as a 4-digit code (each digit from 0 to 4 corresponds to a degree of satisfaction between 1.0 and 0.0).

  2. Construction of the fuzzy function

    • For the four key points, the values are assigned directly.
    • For all other combinations (x, y), the value is calculated by weighted bilinear interpolation, using the formula:

      • vA05B05⋅x⋅y+vA05B1⋅x⋅∣x−y∣+vA0B1⋅(1−x)⋅y

    • This formula produces a continuous surface that remains consistent with the defined key points.

  3. Result

    • The returned function can be applied to any pair (x, y) of fuzzy values.
    • A parameter dictionary is also returned, documenting the type, code, points


Adjustment method for unusual symmetrical criteria

The triplets presented in the function table above comply with the following constraints:

1) R3 >= max( R1,R2), the evaluation of a situation that completely satisfies criterion 2 and moderately satisfies criterion 1 must be at least equal to the best evaluation of the other two situations (R1 and R2), one of which does not satisfy the first criterion at all and the other of which only moderately satisfies both criteria;

2) R3 >= grade C or 0.5, full satisfaction of the second criterion cannot cause the overall satisfaction to fall below the level of satisfaction of the first criterion.

However, although this logic is used in most applications, it may not be appropriate in very specific situations. In this case, the plugin uses the generate_fuzzy_function(code) function to automatically generate a suitable aggregation function.

A warning message indicates that an unusual combination of responses has been encountered.

  1. Key points defined by the user

    • The user defines three reference situations, coded with three digits (from 0 to 4) representing a degree of aggregation between 1.0 and 0.0:

      • (1, 0) or (0, 1): one criterion is completely true, the other completely false->v1
      • (0.5, 0.5): both criteria are average ->v2
      • (0.5, 1) or (1, 0.5): one criterion is average, the other is completely true->v3

  2. Construction of the symmetric fuzzy function

    • The values of the three key points are assigned directly according to the code provided.
    • For all other pairs (x, y), the value is estimated by continuous interpolation using the formula:

      • v2⋅x⋅y+v3⋅∣x−y∣

    • Symmetry is respected because the formula and key points are identical if x and y are swapped.

  3. Result

    • The returned function can be applied to any pair (x, y) of fuzzy values.
    • A parameter dictionary is also returned, documenting the type, code, key points, and approximation formula.


Resulting layer

The resulting layer is automatically added to the current QGis project, with a “graded” symbology.

With 5 classes:

Si cet article vous a intéressé et que vous pensez qu'il pourrait bénéficier à d'autres personnes, n'hésitez pas à le partager sur vos réseaux sociaux en utilisant les boutons ci-dessous. Votre partage est apprécié !

Leave a Reply

Your email address will not be published. Required fields are marked *