0

I'm following the cookbook tutorial on evaluating expressions. QGIS 3.16 using the in-built python editor. I've initiated the context scope in the variable context as per the tutorial. The rest is test code ultimately aiming at updating the double field Rain_D using the contents of the string field Rainfall

# Calculate Rain_D values

context = QgsExpressionContext() context.appendScopes(QgsExpressionContextUtils.globalProjectLayerScopes(weather_l))

n = 0 with edit(weather_l): for fea in weather_l.getFeatures(): n += 1 context.setFeature(fea) if fea['Rainfall'].isalpha(): print(n) weather_l.updateFeature(fea)

The problem is that when the for loop gets to about a thousand or so iterations (it's different every time) QGIS crashes. Any idea what's going on here? It works if I break after a few iterations, but not when going through the 100,000 or so records in weather_l.

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
GlenS
  • 519
  • 3
  • 14
  • This looks like a bug report. Have you considered creating an issue to inform QGIS devs? You can do so at https://github.com/qgis/QGIS/issues/ BTW, you can find some alternatives in this answer. – Germán Carrillo Aug 20 '21 at 01:45
  • I thought it was possibly a bug but I'm new at pyqgis so I wanted to check first. I'll submit it. Thanks. – GlenS Aug 20 '21 at 01:54

0 Answers0