Prevent background execution of zonal stats

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
This commit is contained in:
Nyall Dawson 2018-06-08 08:53:39 +10:00
parent 6bf7c0eb92
commit b637c7fe22

View File

@ -32,6 +32,7 @@ from qgis.PyQt.QtGui import QIcon
from qgis.analysis import QgsZonalStatistics
from qgis.core import (QgsProcessing,
QgsProcessingAlgorithm,
QgsProcessingParameterVectorLayer,
QgsProcessingParameterRasterLayer,
QgsProcessingParameterString,
@ -61,6 +62,9 @@ class ZonalStatistics(QgisAlgorithm):
def groupId(self):
return 'rasteranalysis'
def flags(self):
return super().flags() | QgsProcessingAlgorithm.FlagNoThreading
def __init__(self):
super().__init__()
self.bandNumber = None