Skip to content

Commit

Permalink
feat(processing, wizard-eda): add band parameter to descriptive stati…
Browse files Browse the repository at this point in the history
…stics raster, add field type filter to vector statistics, adjust docstrings
  • Loading branch information
nmaarnio committed Sep 17, 2024
1 parent 18d4e87 commit 30b1a9d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from qgis.core import QgsProcessingParameterRasterLayer
from qgis.core import QgsProcessingParameterBand, QgsProcessingParameterRasterLayer

from eis_qgis_plugin.processing.eis_processing_algorithm import EISProcessingAlgorithm

Expand All @@ -12,17 +12,33 @@ def __init__(self) -> None:
self._group = "Exploratory analysis"
self._group_id = "exploratory_analysis"
self._short_help_string = """
Calculate descriptive statistics for raster data.
Compute descriptive statistics for raster data.
Calculates min, max, mean, quantiles (25%, 50% and 75%), \
standard deviation, relative standard deviation and skewness.
Computes the following statistics:
- min
- max
- mean
- quantiles 25%
- quantile 50% (median)
- quantile 75%
- standard deviation
- relative standard deviation
- skewness
Nodata values are removed from the data before the statistics are computed.
"""

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

input_raster_param = QgsProcessingParameterRasterLayer(
name=self.alg_parameters[0], description="Input raster"
)
input_raster_param.setHelp("Input raster to calculate descriptive statistics for.")
input_raster_param.setHelp("Input raster.")
self.addParameter(input_raster_param)

band_param =QgsProcessingParameterBand(
name=self.alg_parameters[1], description="Band", parentLayerParameterName=self.alg_parameters[0]
)
band_param.setHelp("Raster band to compute descriptive statistics from.")
self.addParameter(band_param)
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from qgis.core import QgsProcessingParameterFeatureSource, QgsProcessingParameterField
from qgis.gui import Qgis

from eis_qgis_plugin.processing.eis_processing_algorithm import EISProcessingAlgorithm

Expand All @@ -12,10 +13,18 @@ def __init__(self) -> None:
self._group = "Exploratory analysis"
self._group_id = "exploratory_analysis"
self._short_help_string = """
Calculate descriptive statistics for vector data.
Calculates min, max, mean, quantiles (25%, 50% and 75%), \
standard deviation, relative standard deviation and skewness.
Compute descriptive statistics for vector data.
Computes the following statistics:
- min
- max
- mean
- quantiles 25%
- quantile 50% (median)
- quantile 75%
- standard deviation
- relative standard deviation
- skewness
"""

def initAlgorithm(self, config=None):
Expand All @@ -24,13 +33,14 @@ def initAlgorithm(self, config=None):
input_vector_param = QgsProcessingParameterFeatureSource(
name=self.alg_parameters[0], description="Input vector"
)
input_vector_param.setHelp("Input vector to calculate descriptive statistics for.")
input_vector_param.setHelp("Input vector.")
self.addParameter(input_vector_param)

column_param = QgsProcessingParameterField(
name=self.alg_parameters[1],
description="Column",
parentLayerParameterName=self.alg_parameters[0],
type=Qgis.ProcessingFieldParameterDataType.Numeric
)
column_param.setHelp("Column selection.")
column_param.setHelp("Column in vector data to compute descriptive statistics from.")
self.addParameter(column_param)
4 changes: 2 additions & 2 deletions eis_qgis_plugin/wizard/eda/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ def compute_descriptive_statistics_and_quantiles(self, layer: QgsMapLayer):
descriptive_statistics_results = processing.run(
"eis:descriptive_statistics_raster",
{
"input_file": self.layer.currentLayer(),
#TODO band
"input_raster": self.layer.currentLayer(),
"band": self.band.currentBand()
},
)

Expand Down

0 comments on commit 30b1a9d

Please sign in to comment.