Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

92 Enhancements to Create constant raster #102

Merged
merged 5 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

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)
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)
Loading