Hi all <div><br></div><div>I am a newcomer to Qgis plugins but not to Python and geoprocessing. Trying my hand at a plugin today I got pretty much to where I want to be in a very short time thanks to the excellent tutorials and logical design of the Python bindings. </div>
<div>However, one issue threw me completely. The cookbook has a great example of getting geometries and attributes ( <a href="http://www.qgis.org/pyqgis-cookbook/vector.html#iterating-over-vector-layer">http://www.qgis.org/pyqgis-cookbook/vector.html#iterating-over-vector-layer</a>) but when it comes to reading the attributes it suggests the code below which produces the attribute *values* but uses integers for keys, even though in general there are field names in the vector data. I consulted with the class definition of the underlying library <a href="http://qgis.sourceforge.net/html/classQgsFeatureAttribute.html">http://qgis.sourceforge.net/html/classQgsFeatureAttribute.html</a> which makes a lot of sense having public methods fieldName ()  and fieldValue(). However, I was not able to find these in the Python bindings. I am sure this is a super simple question reflecting that I have only spend 1 day so far with this so please help me get on the right track.</div>
<div><br></div><div>Cheers and thanks</div><div>Ole Nielsen</div><div>Australia-Indonesia Facility for Disaster Reduction, AusAID, Jakarta</div><div><br></div><div>---------------------------------</div><div>Snippet from cookbook</div>
<div>---------------------------------</div><div><br></div><div><div># fetch map of attributes</div><div>attrs = feat.attributeMap()</div><div><br></div><div># attrs is a dictionary: key = field index, value = QgsFeatureAttribute</div>
<div># show all attributes and their values</div><div>for (k,attr) in attrs.iteritems():</div><div>    print &quot;%d: %s&quot; % (k, attr.toString())   # PROBLEM: This only gives attribute *values* and not their field names. I had expected them to be keys in the dictionary.</div>
</div><div><br></div><div><br></div>