-
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.
Add Unify raster nodata utility processing algorithm
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
eis_qgis_plugin/processing/algorithms/utilities/unify_raster_nodata.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,54 @@ | ||
from qgis.core import ( | ||
QgsProcessing, | ||
QgsProcessingParameterFolderDestination, | ||
QgsProcessingParameterMultipleLayers, | ||
QgsProcessingParameterNumber, | ||
) | ||
|
||
from eis_qgis_plugin.processing.eis_processing_algorithm import EISProcessingAlgorithm | ||
|
||
|
||
class EISUnifyRasterNodata(EISProcessingAlgorithm): | ||
def __init__(self) -> None: | ||
super().__init__() | ||
|
||
self._name = "unify_raster_nodata" | ||
self._display_name = "Unify raster nodata" | ||
self._group = "Utilities" | ||
self._group_id = "utilities" | ||
self._short_help_string = """ | ||
Unifies nodata for the input rasters. | ||
Sets nodata in raster metadata to the specified value and replaces all found old nodata \ | ||
pixels with new nodata pixels for all rasters. | ||
Old nodata values are read from raster metadata. If some raster metadata are incorrect, \ | ||
fix them first with "Set raster nodata" or "Convert raster nodata" tools. | ||
""" | ||
|
||
def initAlgorithm(self, config=None): | ||
self.alg_parameters = ["input_rasters", "new_nodata", "output_dir"] | ||
|
||
input_raster_param = QgsProcessingParameterMultipleLayers( | ||
name=self.alg_parameters[0], | ||
description="Input rasters", | ||
layerType=QgsProcessing.TypeRaster, | ||
) | ||
input_raster_param.setHelp("Input rasters with nodata to be unified.") | ||
self.addParameter(input_raster_param) | ||
|
||
new_nodata_param = QgsProcessingParameterNumber( | ||
name=self.alg_parameters[1], | ||
description="New nodata", | ||
defaultValue=-9999, | ||
type=QgsProcessingParameterNumber.Double, | ||
) | ||
new_nodata_param.setHelp("New nodata value used for the rasters.") | ||
self.addParameter(new_nodata_param) | ||
|
||
output_folder_param = QgsProcessingParameterFolderDestination( | ||
name=self.alg_parameters[2], | ||
description="Output raster" | ||
) | ||
output_folder_param.setHelp("Output folder where the unified rasters will be saved.") | ||
self.addParameter(output_folder_param) |