diff --git a/eis_qgis_plugin/processing/algorithms/raster_processing/create_constant_raster.py b/eis_qgis_plugin/processing/algorithms/raster_processing/create_constant_raster.py deleted file mode 100644 index bf5b64f2..00000000 --- a/eis_qgis_plugin/processing/algorithms/raster_processing/create_constant_raster.py +++ /dev/null @@ -1,62 +0,0 @@ -from qgis.core import ( - QgsProcessingParameterCrs, - QgsProcessingParameterExtent, - QgsProcessingParameterNumber, - QgsProcessingParameterRasterDestination, -) - -from eis_qgis_plugin.processing.eis_processing_algorithm import EISProcessingAlgorithm - - -class EISCreateConstantRaster(EISProcessingAlgorithm): - def __init__(self) -> None: - super().__init__() - - self._name = "create_constant_raster" - self._display_name = "Create constant raster" - self._group = "Raster Processing" - self._group_id = "raster_processing" - self._short_help_string = "Create a constant raster based on a user-defined value." - - def initAlgorithm(self, config=None): - self.alg_parameters = [ - "extent", "target_crs", "pixel_size", "constant_value", "out_raster" - ] - - self.addParameter( - QgsProcessingParameterExtent( - name=self.alg_parameters[0], - description="Extent", - optional=True, - ) - ) - - self.addParameter( - QgsProcessingParameterCrs( - name=self.alg_parameters[1], - description="Target CRS", - optional=True, - ) - ) - - self.addParameter( - QgsProcessingParameterNumber( - name=self.alg_parameters[2], - description="Target pixel size", - # optional=True, - defaultValue=0.01 - ) - ) - - self.addParameter( - QgsProcessingParameterNumber( - name=self.alg_parameters[3], - description="Constant value to use.", - ) - ) - - self.addParameter( - QgsProcessingParameterRasterDestination( - name=self.alg_parameters[4], description="out_raster", - ) - ) diff --git a/eis_qgis_plugin/processing/algorithms/raster_processing/create_constant_raster_from_template.py b/eis_qgis_plugin/processing/algorithms/raster_processing/create_constant_raster_from_template.py new file mode 100644 index 00000000..1891abf2 --- /dev/null +++ b/eis_qgis_plugin/processing/algorithms/raster_processing/create_constant_raster_from_template.py @@ -0,0 +1,56 @@ +from qgis.core import ( + QgsProcessingParameterNumber, + QgsProcessingParameterRasterDestination, + QgsProcessingParameterRasterLayer, +) + +from eis_qgis_plugin.processing.eis_processing_algorithm import EISProcessingAlgorithm + + +class EISCreateConstantRasterFromTemplate(EISProcessingAlgorithm): + def __init__(self) -> None: + super().__init__() + + self._name = "create_constant_raster_from_template" + self._display_name = "Create constant raster from template" + self._group = "Raster Processing" + self._group_id = "raster_processing" + self._short_help_string = "Create a constant raster from a template raster." + + def initAlgorithm(self, config=None): + self.alg_parameters = [ + "constant_value", + "template_raster", + "nodata_value", + "output_raster", + ] + + constant_value_param = QgsProcessingParameterNumber( + name=self.alg_parameters[0], + description="Constant value", + type=QgsProcessingParameterNumber.Double, + ) + constant_value_param.setHelp("The constant value of the output raster.") + self.addParameter(constant_value_param) + + template_raster_param = QgsProcessingParameterRasterLayer( + name=self.alg_parameters[1], + description="Template/base raster", + ) + template_raster_param.setHelp("The raster to use as the template for the output raster grid properties.") + self.addParameter(template_raster_param) + + nodata_value_param = QgsProcessingParameterNumber( + name=self.alg_parameters[2], + description="Nodata value", + type=QgsProcessingParameterNumber.Double, + defaultValue=-9999 + ) + nodata_value_param.setHelp("The nodata value of the output raster.") + self.addParameter(nodata_value_param) + + output_raster_param = QgsProcessingParameterRasterDestination( + name=self.alg_parameters[3], description="Output raster" + ) + output_raster_param.setHelp("The output constant raster.") + self.addParameter(output_raster_param) diff --git a/eis_qgis_plugin/processing/algorithms/raster_processing/create_constant_raster_manually.py b/eis_qgis_plugin/processing/algorithms/raster_processing/create_constant_raster_manually.py new file mode 100644 index 00000000..aecf3a62 --- /dev/null +++ b/eis_qgis_plugin/processing/algorithms/raster_processing/create_constant_raster_manually.py @@ -0,0 +1,78 @@ +from qgis.core import ( + QgsProcessingParameterCrs, + QgsProcessingParameterExtent, + QgsProcessingParameterNumber, + QgsProcessingParameterRasterDestination, +) + +from eis_qgis_plugin.processing.eis_processing_algorithm import EISProcessingAlgorithm + + +class EISCreateConstantRasterManually(EISProcessingAlgorithm): + def __init__(self) -> None: + super().__init__() + + self._name = "create_constant_raster_manually" + self._display_name = "Create constant raster manually" + self._group = "Raster Processing" + self._group_id = "raster_processing" + self._short_help_string = """ + Create a constant raster manually by defining CRS, extent and pixel size. + + If the resulting raster height and width are not exact multiples of the pixel size, the \ + output raster extent will differ slightly from the defined extent. + """ + + def initAlgorithm(self, config=None): + self.alg_parameters = [ + "constant_value", + "target_epsg", + "extent", + "target_pixel_size", + "nodata_value", + "output_raster", + ] + + constant_value_param = QgsProcessingParameterNumber( + name=self.alg_parameters[0], + description="Constant value", + type=QgsProcessingParameterNumber.Double, + ) + constant_value_param.setHelp("The constant value of the output raster.") + self.addParameter(constant_value_param) + + target_epsg_param = QgsProcessingParameterCrs( + name=self.alg_parameters[1], + description="Target CRS", + ) + target_epsg_param.setHelp("The CRS of the output raster.") + self.addParameter(target_epsg_param) + + extent_param = QgsProcessingParameterExtent( + name=self.alg_parameters[2], + description="Extent", + ) + extent_param.setHelp("The extent of the output raster.") + self.addParameter(extent_param) + + target_pixel_size_param = QgsProcessingParameterNumber( + name=self.alg_parameters[3], + description="Target pixel size", + ) + target_pixel_size_param.setHelp("The pixel size of the output raster.") + self.addParameter(target_pixel_size_param) + + nodata_value_param = QgsProcessingParameterNumber( + name=self.alg_parameters[4], + description="Nodata value", + type=QgsProcessingParameterNumber.Double, + defaultValue=-9999 + ) + nodata_value_param.setHelp("The nodata value of the output raster.") + self.addParameter(nodata_value_param) + + output_raster_param = QgsProcessingParameterRasterDestination( + name=self.alg_parameters[5], description="Output raster" + ) + output_raster_param.setHelp("The output constant raster.") + self.addParameter(output_raster_param)