Skip to content

Commit

Permalink
Prevent background execution of zonal stats
Browse files Browse the repository at this point in the history
This algorithm is NEVER safe to run in the background, because
it directly modifies a layer in place.

We should:
- make a variant of this algorithm which returns a new layer
AND
- refactor the QgsZonalStats code to create a separate map
of feature->stats, and then modify the existing Zonal Stats
algorithm to apply these changes in a post processing step
  • Loading branch information
nyalldawson committed Jun 8, 2018
1 parent 6bf7c0e commit b637c7f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions python/plugins/processing/algs/qgis/ZonalStatistics.py
Expand Up @@ -32,6 +32,7 @@

from qgis.analysis import QgsZonalStatistics
from qgis.core import (QgsProcessing,
QgsProcessingAlgorithm,
QgsProcessingParameterVectorLayer,
QgsProcessingParameterRasterLayer,
QgsProcessingParameterString,
Expand Down Expand Up @@ -61,6 +62,9 @@ def group(self):
def groupId(self):
return 'rasteranalysis'

def flags(self):
return super().flags() | QgsProcessingAlgorithm.FlagNoThreading

def __init__(self):
super().__init__()
self.bandNumber = None
Expand Down

0 comments on commit b637c7f

Please sign in to comment.