Skip to content

Commit 667ba42

Browse files
committed
[processing] correctly handle null gems in meancoords alg
Fixes #17026
1 parent 7ca8de9 commit 667ba42

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,14 @@ def processAlgorithm(self, progress):
124124
current = 0
125125
total = 100.0 / len(means)
126126
for (clazz, values) in means.iteritems():
127-
outFeat = QgsFeature()
128-
cx = values[0] / values[2]
129-
cy = values[1] / values[2]
130-
meanPoint = QgsPoint(cx, cy)
131-
132-
outFeat.setGeometry(QgsGeometry.fromPoint(meanPoint))
133-
outFeat.setAttributes([cx, cy, clazz])
134-
writer.addFeature(outFeat)
127+
if values[2]:
128+
outFeat = QgsFeature()
129+
cx = values[0] / values[2]
130+
cy = values[1] / values[2]
131+
meanPoint = QgsPoint(cx, cy)
132+
outFeat.setGeometry(QgsGeometry.fromPoint(meanPoint))
133+
outFeat.setAttributes([cx, cy, clazz])
134+
writer.addFeature(outFeat)
135135
current += 1
136136
progress.setPercentage(int(current * total))
137137

0 commit comments

Comments
 (0)