[Qgis-developer] How to get the field values in PyQGis 2 ?
gene
martin.laloux at gmail.com
Thu Oct 24 10:40:23 PDT 2013
and you can use a simple dictionary:
fields = layer.pendingFields()
field_names = [field.name() for field in fields]
for elem in layer.getFeatures():
atr = dict(zip(field_names, elem.attributes()))
The result is a Python dictionary:
{u'DIP_DIR': 120, u'STRATI_TYP': 1, u'DIP': 30}}, for example
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/How-to-get-the-field-values-in-PyQGis-2-tp5085274p5085628.html
Sent from the Quantum GIS - Developer mailing list archive at Nabble.com.
More information about the Qgis-developer
mailing list