Skip to content

Commit 9562b9d

Browse files
committed
[processing] only pass needed raster entries in QgsRasterCalculator constructor
1 parent 5fa5b86 commit 9562b9d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

python/plugins/processing/algs/qgis/RasterCalculator.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,13 @@ def _cellsize(layer):
165165
entries = []
166166
for name, lyr in layersDict.items():
167167
for n in range(lyr.bandCount()):
168-
entry = QgsRasterCalculatorEntry()
169-
entry.ref = '{:s}@{:d}'.format(name, n + 1)
170-
entry.raster = lyr
171-
entry.bandNumber = n + 1
172-
entries.append(entry)
168+
ref = '{:s}@{:d}'.format(name, n + 1)
169+
if ref in expression:
170+
entry = QgsRasterCalculatorEntry()
171+
entry.ref = ref
172+
entry.raster = lyr
173+
entry.bandNumber = n + 1
174+
entries.append(entry)
173175

174176
output = self.parameterAsOutputLayer(parameters, self.OUTPUT, context)
175177

0 commit comments

Comments
 (0)