Skip to content

Commit

Permalink
Merge pull request #127 from GispoCoding/126-add-documentation-to-tra…
Browse files Browse the repository at this point in the history
…nsformation-processing-algorithms

Added documentation to transformation processing algorithms
  • Loading branch information
nmaarnio authored Apr 10, 2024
2 parents 703b60e + 36f8554 commit 9951692
Show file tree
Hide file tree
Showing 15 changed files with 356 additions and 309 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,34 @@ def __init__(self) -> None:
def initAlgorithm(self, config=None):
self.alg_parameters = ["input_vector", "column", "keep_denominator_column", "output_vector"]

self.addParameter(
QgsProcessingParameterFeatureSource(
name=self.alg_parameters[0], description="Input vector"
)
input_vector_param = QgsProcessingParameterFeatureSource(
name=self.alg_parameters[0], description="Input vector"
)

self.addParameter(
QgsProcessingParameterField(
name=self.alg_parameters[1],
description="Denominator column",
parentLayerParameterName=self.alg_parameters[0],
optional=True,
)
input_vector_param.setHelp("Input vector with compositional data.")
self.addParameter(input_vector_param)

denominator_column_param = QgsProcessingParameterField(
name=self.alg_parameters[1],
description="Denominator column",
parentLayerParameterName=self.alg_parameters[0],
optional=True,
)
denominator_column_param.setHelp("The column to be used as the denominator column.")
self.addParameter(denominator_column_param)

self.addParameter(
QgsProcessingParameterBoolean(
name=self.alg_parameters[2],
description="Keep denominator column",
defaultValue=False
)
keep_denominator_column_param = QgsProcessingParameterBoolean(
name=self.alg_parameters[2],
description="Keep denominator column",
defaultValue=False
)
keep_denominator_column_param.setHelp(
"Whether to include the used denominator column in the result."
)
self.addParameter(keep_denominator_column_param)

self.addParameter(
QgsProcessingParameterVectorDestination(
name=self.alg_parameters[3],
description="Output vector",
)
output_vector_param = QgsProcessingParameterVectorDestination(
name=self.alg_parameters[3],
description="Output vector",
)
output_vector_param.setHelp("Output vector with the ALR transformed data.")
self.addParameter(output_vector_param)
39 changes: 22 additions & 17 deletions eis_qgis_plugin/processing/algorithms/transformations/binarize.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,33 @@ def __init__(self) -> None:
self._display_name = "Binarize"
self._group = "Transformations"
self._group_id = "transformations"
self._short_help_string = "Calculate binarize transformation for data"
self._short_help_string = """
Binarize data based on a given threshold.
Replaces values less or equal threshold with 0. \
Replaces values greater than the threshold with 1.
"""

def initAlgorithm(self, config=None):
self.alg_parameters = ["input_raster", "threshold", "output_raster"]

self.addParameter(
QgsProcessingParameterRasterLayer(
name=self.alg_parameters[0], description="Input raster"
)

input_vector_param = QgsProcessingParameterRasterLayer(
name=self.alg_parameters[0], description="Input raster"
)
input_vector_param.setHelp("Input raster to be binarized.")
self.addParameter(input_vector_param)

self.addParameter(
QgsProcessingParameterNumber(
name=self.alg_parameters[1],
description="Binarizing threshold",
type=QgsProcessingParameterNumber.Double,
)
binarizing_threshold_param = QgsProcessingParameterNumber(
name=self.alg_parameters[1],
description="Binarizing threshold",
type=QgsProcessingParameterNumber.Double,
)
binarizing_threshold_param.setHelp("Threshold value for binarization.")
self.addParameter(binarizing_threshold_param)

self.addParameter(
QgsProcessingParameterRasterDestination(
name=self.alg_parameters[2],
description="Output raster",
)
output_raster_param = QgsProcessingParameterRasterDestination(
name=self.alg_parameters[2],
description="Output raster",
)
output_raster_param.setHelp("Output raster with transformed data.")
self.addParameter(output_raster_param)
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ def __init__(self) -> None:
self._display_name = "Clip transform"
self._group = "Transformations"
self._group_id = "transformations"
self._short_help_string = (
"Clips data based on specified upper and lower limits."
)
self._short_help_string = """
Clips data based on specified upper and lower limits.
Replaces values below the lower limit and above the upper limit with provided values, respecively.
Works both one-sided and two-sided but raises error if no limits provided.
"""

def initAlgorithm(self, config=None):
self.alg_parameters = [
Expand All @@ -27,32 +30,32 @@ def initAlgorithm(self, config=None):
"output_raster",
]

self.addParameter(
QgsProcessingParameterRasterLayer(
name=self.alg_parameters[0], description="Input raster"
)
input_raster_param = QgsProcessingParameterRasterLayer(
name=self.alg_parameters[0], description="Input raster"
)

self.addParameter(
QgsProcessingParameterNumber(
name=self.alg_parameters[1],
description="Lower",
type=QgsProcessingParameterNumber.Double,
optional=True,
)
input_raster_param.setHelp("Input raster to be clipped.")
self.addParameter(input_raster_param)

lower_limit_param = QgsProcessingParameterNumber(
name=self.alg_parameters[1],
description="Lower",
type=QgsProcessingParameterNumber.Double,
optional=True,
)

self.addParameter(
QgsProcessingParameterNumber(
name=self.alg_parameters[2],
description="Higher",
type=QgsProcessingParameterNumber.Double,
optional=True,
)
lower_limit_param.setHelp("Lower transformation limit.")
self.addParameter(lower_limit_param)

higher_limit_param = QgsProcessingParameterNumber(
name=self.alg_parameters[2],
description="Higher",
type=QgsProcessingParameterNumber.Double,
optional=True,
)
higher_limit_param.setHelp("Higher transformation limit.")
self.addParameter(higher_limit_param)

self.addParameter(
QgsProcessingParameterRasterDestination(
name=self.alg_parameters[3], description="Output raster"
)
output_raster_param = QgsProcessingParameterRasterDestination(
name=self.alg_parameters[3], description="Output raster"
)
output_raster_param.setHelp("Output raster with transformed data.")
self.addParameter(output_raster_param)
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ def __init__(self) -> None:
def initAlgorithm(self, config=None):
self.alg_parameters = ["input_vector", "output_vector"]

self.addParameter(
QgsProcessingParameterFeatureSource(
name=self.alg_parameters[0], description="Input vector"
)
input_vector_param = QgsProcessingParameterFeatureSource(
name=self.alg_parameters[0], description="Input vector"
)
input_vector_param.setHelp("Input vector with compositional data.")
self.addParameter(input_vector_param)

self.addParameter(
QgsProcessingParameterVectorDestination(
name=self.alg_parameters[1],
description="Output vector",
)
output_vector_param = QgsProcessingParameterVectorDestination(
name=self.alg_parameters[1],
description="Output vector",
)
output_vector_param.setHelp("Output vector with the CLR transformed data.")
self.addParameter(output_vector_param)
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,37 @@ def __init__(self) -> None:
self._group_id = "transformations"
self._short_help_string = "Perform the inverse transformation for a set of ALR transformed data."


def initAlgorithm(self, config=None):
self.alg_parameters = ["input_vector", "denominator_column", "scale", "output_vector"]

self.addParameter(
QgsProcessingParameterFeatureSource(
name=self.alg_parameters[0], description="Input vector"
)
input_vector_param = QgsProcessingParameterFeatureSource(
name=self.alg_parameters[0], description="Input vector"
)
input_vector_param.setHelp("Input vector with ALR transformed compositional data.")
self.addParameter(input_vector_param)

self.addParameter(
QgsProcessingParameterString(
name=self.alg_parameters[1],
description="Denominator column name",
)
denominator_column_name_param = QgsProcessingParameterString(
name=self.alg_parameters[1],
description="Denominator column name",
)

self.addParameter(
QgsProcessingParameterNumber(
name=self.alg_parameters[2],
description="Scale",
defaultValue=1.0,
type=QgsProcessingParameterNumber.Double
)
denominator_column_name_param.setHelp("The name of the denominator column.")
self.addParameter(denominator_column_name_param)

scale_param = QgsProcessingParameterNumber(
name=self.alg_parameters[2],
description="Scale",
defaultValue=1.0,
type=QgsProcessingParameterNumber.Double
)
scale_param.setHelp(
"The value to which each composition should be normalized. \
Eg., if the composition is expressed as percentages, scale=100."
)
self.addParameter(scale_param)

self.addParameter(
QgsProcessingParameterVectorDestination(
name=self.alg_parameters[3],
description="Output vector",
)
output_vector_param = QgsProcessingParameterVectorDestination(
name=self.alg_parameters[3],
description="Output vector",
)
output_vector_param.setHelp("Output vector with inverse transformed data.")
self.addParameter(output_vector_param)
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,31 @@ def __init__(self) -> None:
self._group_id = "transformations"
self._short_help_string = "Perform the inverse transformation for a set of CLR transformed data."


def initAlgorithm(self, config=None):
self.alg_parameters = ["input_vector", "scale", "output_vector"] # NOTE: Colnames param omitted

self.addParameter(
QgsProcessingParameterFeatureSource(
name=self.alg_parameters[0], description="Input vector"
)
input_vector_param = QgsProcessingParameterFeatureSource(
name=self.alg_parameters[0], description="Input vector"
)

self.addParameter(
QgsProcessingParameterNumber(
name=self.alg_parameters[1],
description="Scale",
defaultValue=1.0,
type=QgsProcessingParameterNumber.Double
)
input_vector_param.setHelp("Input vector with CLR transformed compositional data.")
self.addParameter(input_vector_param)

scale_param = QgsProcessingParameterNumber(
name=self.alg_parameters[1],
description="Scale",
defaultValue=1.0,
type=QgsProcessingParameterNumber.Double
)
scale_param.setHelp(
"The value to which each composition should be normalized. \
Eg., if the composition is expressed as percentages, scale=100."
)
self.addParameter(scale_param)

self.addParameter(
QgsProcessingParameterVectorDestination(
name=self.alg_parameters[2],
description="Output vector",
)
output_vector_param = QgsProcessingParameterVectorDestination(
name=self.alg_parameters[2],
description="Output vector",
)
output_vector_param.setHelp("Output vector with inverse transformed data.")
self.addParameter(output_vector_param)

Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,27 @@ def __init__(self) -> None:
self._display_name = "Logarithmic transform"
self._group = "Transformations"
self._group_id = "transformations"
self._short_help_string = (
"Perform a logarithmic transformation on the provided data."
)
self._short_help_string = "Perform a logarithmic transformation on the provided data."

def initAlgorithm(self, config=None):
self.alg_parameters = ["input_raster", "log_type", "output_raster"]

self.addParameter(
QgsProcessingParameterRasterLayer(
name=self.alg_parameters[0], description="Input raster"
)
input_raster_param = QgsProcessingParameterRasterLayer(
name=self.alg_parameters[0], description="Input raster"
)
input_raster_param.setHelp("Input raster to be transformed.")
self.addParameter(input_raster_param)

self.addParameter(
QgsProcessingParameterEnum(
name=self.alg_parameters[1],
description="Lower",
options=["log2", "log10", "ln"],
)
log_type_param = QgsProcessingParameterEnum(
name=self.alg_parameters[1],
description="Log type",
options=["log2", "log10", "ln"],
)
log_type_param.setHelp("The base for logarithmic transformation.")
self.addParameter(log_type_param)

self.addParameter(
QgsProcessingParameterRasterDestination(
name=self.alg_parameters[2], description="Output raster"
)
output_raster_param = QgsProcessingParameterRasterDestination(
name=self.alg_parameters[2], description="Output raster"
)
output_raster_param.setHelp("Output raster with transformed data.")
self.addParameter(output_raster_param)
Loading

0 comments on commit 9951692

Please sign in to comment.