-
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.
92 Enhancements to Create constant raster (#102)
* Modify Create constant raster to be compatible with EIS toolkit --------- Co-authored-by: Niko Aarnio <[email protected]>
- Loading branch information
Showing
3 changed files
with
134 additions
and
62 deletions.
There are no files selected for viewing
62 changes: 0 additions & 62 deletions
62
eis_qgis_plugin/processing/algorithms/raster_processing/create_constant_raster.py
This file was deleted.
Oops, something went wrong.
56 changes: 56 additions & 0 deletions
56
...is_plugin/processing/algorithms/raster_processing/create_constant_raster_from_template.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,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) |
78 changes: 78 additions & 0 deletions
78
eis_qgis_plugin/processing/algorithms/raster_processing/create_constant_raster_manually.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,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) |