0

The code below is not working: This code doesn't affect the table at all

layer = point_layer3
selected_feature = layer.selectedFeatures()
print(len(selected_feature))
layer.startEditing()

for feature in selected_feature:
    a = f['parkeer_approx']

    b = parking_capacity[f.id()-int(1)]['parking_capacity']
    feature["parkeer_approx"] = a - b
    layer.updateFeature(feature)

layer.commitChanges()
MrXsquared
  • 34,292
  • 21
  • 67
  • 117

1 Answers1

3

Similar to what @Joseph pointed out in the comments, in the lines where you set a and b did you mean to use "f" instead of "feature"? Try the updates below:

for feature in selected_feature:
    a = feature['parkeer_approx']

    b = parking_capacity[feature.id()-int(1)]['parking_capacity']
    feature["parkeer_approx"] = a - b
    layer.updateFeature(feature)
ycartwhelen
  • 2,392
  • 10
  • 20