Last active
August 29, 2015 14:08
-
-
Save NathanW2/8c981db9b31d00457cc0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def change_values(layer, **kwargs): | |
featuremap = {} | |
for feature, values in kwargs.iteritems(): | |
attrs = {} | |
for field, value in values.iteritems(): | |
index = layer.dataProvider().fieldNameIndex(field) | |
attrs[index] = value | |
featuremap[feature.id()] = attrs | |
return layer.dataProvider().changeAttributeValues(featuremap) | |
features = {feature1: {"field1": 1, "field2": 2}, | |
feature2: {"field1": 1}} | |
change_values(layer, features) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment