-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(algorithms): add mask raster processing algorithm
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
eis_qgis_plugin/processing/algorithms/raster_processing/mask_raster.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from qgis.core import QgsProcessingParameterRasterDestination, QgsProcessingParameterRasterLayer | ||
|
||
from eis_qgis_plugin.processing.eis_processing_algorithm import EISProcessingAlgorithm | ||
|
||
|
||
class EISMaskRaster(EISProcessingAlgorithm): | ||
def __init__(self) -> None: | ||
super().__init__() | ||
|
||
self._name = "mask_raster" | ||
self._display_name = "Mask raster" | ||
self._group = "Raster Processing" | ||
self._group_id = "raster_processing" | ||
self._short_help_string = """ | ||
Mask input raster using the nodata locations from base raster. | ||
Only the first band of base raster is used to scan for nodata cells. Masking is performed to all \ | ||
bands of input raster. | ||
If input rasters have mismatching grid properties, unifies rasters before masking (uses `nearest` \ | ||
resampling, unify separately first if you need control over the resampling method). | ||
""" | ||
|
||
def initAlgorithm(self, config=None): | ||
self.alg_parameters = ["input_raster", "base_raster", "output_raster"] | ||
|
||
input_raster_param = QgsProcessingParameterRasterLayer( | ||
name=self.alg_parameters[0], description="Input raster" | ||
) | ||
input_raster_param.setHelp("Input raster to be masked.") | ||
self.addParameter(input_raster_param) | ||
|
||
base_raster_param = QgsProcessingParameterRasterLayer( | ||
name=self.alg_parameters[1], description="Base raster", | ||
) | ||
base_raster_param.setHelp("The base raster used to determine nodata locations.") | ||
self.addParameter(base_raster_param) | ||
|
||
output_raster_param = QgsProcessingParameterRasterDestination( | ||
name=self.alg_parameters[2], description="Output raster" | ||
) | ||
output_raster_param.setHelp("The masked output raster.") | ||
self.addParameter(output_raster_param) |