Focal
focal_filter(raster, method='mean', size=3, shape='circle')
Apply a basic focal filter to the input raster.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
raster |
DatasetReader
|
The input raster dataset. |
required |
method |
Literal[mean, median]
|
The method to use for filtering. Can be either "mean" or "median". Default to "mean". |
'mean'
|
size |
int
|
The size of the filter window. E.g., 3 means a 3x3 window. Default to 3. |
3
|
shape |
Literal[square, circle]
|
The shape of the filter window. Can be either "square" or "circle". Default to "circle". |
'circle'
|
Returns:
Type | Description |
---|---|
tuple[ndarray, dict]
|
The filtered raster array. |
Raises:
Type | Description |
---|---|
InvalidRasterBandException
|
If the input raster has more than one band. |
InvalidParameterValueException
|
If the filter size is smaller than 3. If the filter size is not an odd number. If the shape is not "square" or "circle". |
Source code in eis_toolkit/raster_processing/filters/focal.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|
gaussian_filter(raster, sigma=1, truncate=4, size=None)
Apply a gaussian filter to the input raster.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
raster |
DatasetReader
|
The input raster dataset. |
required |
sigma |
Number
|
The standard deviation of the gaussian kernel. |
1
|
truncate |
Number
|
The truncation factor for the gaussian kernel based on the sigma value. Only if size is not given. Default to 4.0. E.g., for sigma = 1 and truncate = 4.0, the kernel size is 9x9. |
4
|
size |
Optional[int]
|
The size of the filter window. E.g., 3 means a 3x3 window. If size is not None, it overrides the dynamic size calculation based on sigma and truncate. Default to None. |
None
|
Returns:
Type | Description |
---|---|
tuple[ndarray, dict]
|
The filtered raster array. |
Raises:
Type | Description |
---|---|
InvalidRasterBandException
|
If the input raster has more than one band. |
InvalidParameterValueException
|
If the filter size is smaller than 3. If the filter size is not an odd number. If the resulting radius is smaller than 1. |
Source code in eis_toolkit/raster_processing/filters/focal.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
|
mexican_hat_filter(raster, sigma=1, truncate=4, size=None, direction='circular')
Apply a mexican hat filter to the input raster.
Circular: Lowpass filter for smoothing. Rectangular: Highpass filter for edge detection. Results may need further normalization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
raster |
DatasetReader
|
The input raster dataset. |
required |
sigma |
Number
|
The standard deviation. |
1
|
truncate |
Number
|
The truncation factor. E.g., for sigma = 1 and truncate = 4.0, the kernel size is 9x9. Default to 4.0. |
4
|
size |
Optional[int]
|
The size of the filter window. E.g., 3 means a 3x3 window. Default to None. |
None
|
direction |
Literal[rectangular, circular]
|
The direction of calculating the kernel values. Can be either "rectangular" or "circular". Default to "circular". |
'circular'
|
Returns:
Type | Description |
---|---|
tuple[ndarray, dict]
|
The filtered raster array. |
Raises:
Type | Description |
---|---|
InvalidRasterBandException
|
If the input raster has more than one band. |
InvalidParameterValueException
|
If the filter size is smaller than 3. If the filter size is not an odd number. If the resulting radius is smaller than 1. |
Source code in eis_toolkit/raster_processing/filters/focal.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
|