Skip to content

Fuzzy overlay

and_overlay(data)

Compute an 'and' overlay operation with fuzzy logic.

Parameters:

Name Type Description Default
data Union[Sequence[ndarray], ndarray]

The input data as a series of 2D/3D Numpy arrays or as a 3D Numpy array. All found 2D arrays are overlayed. Input data should contain at least 2D Numpy arrays and data should be in the range [0, 1].

required

Returns:

Type Description
ndarray

2D Numpy array with the result of the 'and' overlay operation. Values are in range [0, 1].

Raises:

Type Description
InvalidDatasetException

If input data contains less than two 2D Numpy arrays/raster bands.

InvalidParameterValueException

If data values are not in range [0, 1].

Source code in eis_toolkit/prediction/fuzzy_overlay.py
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
@beartype
def and_overlay(data: Union[Sequence[np.ndarray], np.ndarray]) -> np.ndarray:
    """Compute an 'and' overlay operation with fuzzy logic.

    Args:
        data: The input data as a series of 2D/3D Numpy arrays or as a 3D Numpy array.
            All found 2D arrays are overlayed. Input data should contain at least 2D Numpy
            arrays and data should be in the range [0, 1].

    Returns:
        2D Numpy array with the result of the 'and' overlay operation. Values are in range [0, 1].

    Raises:
        InvalidDatasetException: If input data contains less than two 2D Numpy arrays/raster bands.
        InvalidParameterValueException: If data values are not in range [0, 1].

    """
    data = _prepare_data_for_fuzzy_overlay(data)
    return data.min(axis=0)

gamma_overlay(data, gamma=0.5)

Compute a 'gamma' overlay operation with fuzzy logic.

Parameters:

Name Type Description Default
data Union[Sequence[ndarray], ndarray]

The input data as a series of 2D/3D Numpy arrays or as a 3D Numpy array. All found 2D arrays are overlayed. Input data should contain at least 2D Numpy arrays and data should be in the range [0, 1].

required
gamma float

The gamma parameter. With gamma value of 0, the result will be the same as 'product' overlay. When gamma is closer to 1, the weight of the 'sum' overlay is increased. Defaults to 0.5. Value must be in the range [0, 1].

0.5

Returns:

Type Description
ndarray

2D Numpy array with the result of the 'gamma' overlay operation. Values are in range [0, 1].

Raises:

Type Description
InvalidDatasetException

If input data contains less than two 2D Numpy arrays/raster bands.

InvalidParameterValueException

If data values or gamma are not in range [0, 1].

Source code in eis_toolkit/prediction/fuzzy_overlay.py
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
@beartype
def gamma_overlay(data: Union[Sequence[np.ndarray], np.ndarray], gamma: float = 0.5) -> np.ndarray:
    """Compute a 'gamma' overlay operation with fuzzy logic.

    Args:
        data: The input data as a series of 2D/3D Numpy arrays or as a 3D Numpy array.
            All found 2D arrays are overlayed. Input data should contain at least 2D Numpy
            arrays and data should be in the range [0, 1].
        gamma: The gamma parameter. With gamma value of 0, the result will be the same as 'product' overlay.
            When gamma is closer to 1, the weight of the 'sum' overlay is increased. Defaults to 0.5.
            Value must be in the range [0, 1].

    Returns:
        2D Numpy array with the result of the 'gamma' overlay operation. Values are in range [0, 1].

    Raises:
        InvalidDatasetException: If input data contains less than two 2D Numpy arrays/raster bands.
        InvalidParameterValueException: If data values or gamma are not in range [0, 1].
    """
    data = _prepare_data_for_fuzzy_overlay(data)
    if gamma < 0 or gamma > 1:
        raise InvalidParameterValueException("The gamma parameter must be in range [0, 1]")

    product = np.prod(data, axis=0)
    sum = data.sum(axis=0) - product
    return product ** (1 - gamma) * sum**gamma

or_overlay(data)

Compute an 'or' overlay operation with fuzzy logic.

Parameters:

Name Type Description Default
data Union[Sequence[ndarray], ndarray]

The input data as a series of 2D/3D Numpy arrays or as a 3D Numpy array. All found 2D arrays are overlayed. Input data should contain at least 2D Numpy arrays and data should be in the range [0, 1].

required

Returns:

Type Description
ndarray

2D Numpy array with the result of the 'or' overlay operation. Values are in range [0, 1].

Raises:

Type Description
InvalidDatasetException

If input data contains less than two 2D Numpy arrays/raster bands.

InvalidParameterValueException

If data values are not in range [0, 1].

Source code in eis_toolkit/prediction/fuzzy_overlay.py
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
@beartype
def or_overlay(data: Union[Sequence[np.ndarray], np.ndarray]) -> np.ndarray:
    """Compute an 'or' overlay operation with fuzzy logic.

    Args:
        data: The input data as a series of 2D/3D Numpy arrays or as a 3D Numpy array.
            All found 2D arrays are overlayed. Input data should contain at least 2D Numpy
            arrays and data should be in the range [0, 1].

    Returns:
        2D Numpy array with the result of the 'or' overlay operation. Values are in range [0, 1].

    Raises:
        InvalidDatasetException: If input data contains less than two 2D Numpy arrays/raster bands.
        InvalidParameterValueException: If data values are not in range [0, 1].
    """
    data = _prepare_data_for_fuzzy_overlay(data)
    return data.max(axis=0)

product_overlay(data)

Compute a 'product' overlay operation with fuzzy logic.

Parameters:

Name Type Description Default
data Union[Sequence[ndarray], ndarray]

The input data as a series of 2D/3D Numpy arrays or as a 3D Numpy array. All found 2D arrays are overlayed. Input data should contain at least 2D Numpy arrays and data should be in the range [0, 1].

required

Returns:

Type Description
ndarray

2D Numpy array with the result of the 'product' overlay operation. Values are in range [0, 1].

Raises:

Type Description
InvalidDatasetException

If input data contains less than two 2D Numpy arrays/raster bands.

InvalidParameterValueException

If data values are not in range [0, 1].

Source code in eis_toolkit/prediction/fuzzy_overlay.py
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
@beartype
def product_overlay(data: Union[Sequence[np.ndarray], np.ndarray]) -> np.ndarray:
    """Compute a 'product' overlay operation with fuzzy logic.

    Args:
        data: The input data as a series of 2D/3D Numpy arrays or as a 3D Numpy array.
            All found 2D arrays are overlayed. Input data should contain at least 2D Numpy
            arrays and data should be in the range [0, 1].

    Returns:
        2D Numpy array with the result of the 'product' overlay operation. Values are in range [0, 1].

    Raises:
        InvalidDatasetException: If input data contains less than two 2D Numpy arrays/raster bands.
        InvalidParameterValueException: If data values are not in range [0, 1].
    """
    data = _prepare_data_for_fuzzy_overlay(data)
    return np.prod(data, axis=0)

sum_overlay(data)

Compute a 'sum' overlay operation with fuzzy logic.

Parameters:

Name Type Description Default
data Union[Sequence[ndarray], ndarray]

The input data as a series of 2D/3D Numpy arrays or as a 3D Numpy array. All found 2D arrays are overlayed. Input data should contain at least 2D Numpy arrays and data should be in the range [0, 1].

required

Returns:

Type Description
ndarray

2D Numpy array with the result of the 'sum' overlay operation. Values are in range [0, 1].

Raises:

Type Description
InvalidDatasetException

If input data contains less than two 2D Numpy arrays/raster bands.

InvalidParameterValueException

If data values are not in range [0, 1].

Source code in eis_toolkit/prediction/fuzzy_overlay.py
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
@beartype
def sum_overlay(data: Union[Sequence[np.ndarray], np.ndarray]) -> np.ndarray:
    """Compute a 'sum' overlay operation with fuzzy logic.

    Args:
        data: The input data as a series of 2D/3D Numpy arrays or as a 3D Numpy array.
            All found 2D arrays are overlayed. Input data should contain at least 2D Numpy
            arrays and data should be in the range [0, 1].

    Returns:
        2D Numpy array with the result of the 'sum' overlay operation. Values are in range [0, 1].

    Raises:
        InvalidDatasetException: If input data contains less than two 2D Numpy arrays/raster bands.
        InvalidParameterValueException: If data values are not in range [0, 1].
    """
    data = _prepare_data_for_fuzzy_overlay(data)
    return data.sum(axis=0) - np.prod(data, axis=0)