Marco,<br><br>Thanks for the direction, I got it working.  As it turns out I had tried something close to the correct way at one point but was making it harder than it it is.<br><br>Thanks again,<br><br>Matt<br><br><div class="gmail_quote">
On Sat, Jul 18, 2009 at 3:44 AM, Hugentobler  Marco <span dir="ltr">&lt;<a href="mailto:marco.hugentobler@karto.baug.ethz.ch">marco.hugentobler@karto.baug.ethz.ch</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Matthew<br>
<br>
You need to first find out what index the attribute with name &#39;Elevation&#39; has. QgsAttributeMap uses that index number, not the field name.<br>
You may find out the index of a field name by using the function fieldNameIndex of QgsVectorDataProvider<br>
<br>
int fieldNameIndex(const QString&amp; fieldName)<br>
<br>
But that gives you only the commited fields. If you also want to consider the not-commited fields, you could work with QgsVectorLayer::pendingFields<br>
<br>
Then, once you have the index, query the value of QgsAttributeMap for this index. QgsAttribute Map is a map (or a dict in python) with key int (the index) and QVariant value (the attribute value).<br>
<br>
Regards,<br>
Marco<br>
<br>
<br>
-----Ursprüngliche Nachricht-----<br>
Von: <a href="mailto:qgis-developer-bounces@lists.osgeo.org">qgis-developer-bounces@lists.osgeo.org</a> im Auftrag von Matthew Denno<br>
Gesendet: Sa 18.07.2009 05:45<br>
An: qgis-developer<br>
Betreff: [Qgis-developer] Using QgsAttributeMap to get feature attributevalue<br>
<div><div></div><div class="h5"><br>
Hi,<br>
<br>
I am having a problem that I am hoping someone can help me with.  I have a<br>
piece of code that iterates through a feature class and pulls out the x and<br>
y coordinates from the geometry.  The z values are stored in the attribute<br>
table and I would also like to pull that value for each feature.  I have<br>
looked at Tutorial 6, but it looks like the classes have changed since it<br>
was written, I think.  I can see that feature.attributeMap() returns a<br>
dictionary of Key-Value pairs (I think) but I can&#39;t figure out how to get<br>
the &quot;Elevation&quot; field attribute value from that.  Here is the piece of code:<br>
<br>
 while (mypVectorLayer-&gt;nextFeature(currentFeature))<br>
<br>
{<br>
<br>
//get geometry of the feature<br>
<br>
QgsGeometry* currentGeometry = currentFeature.geometry();<br>
<br>
QgsPoint currentPoint = currentGeometry-&gt;asPoint();<br>
<br>
<br>
 //get the attributes of this feature<br>
<br>
const QgsAttributeMap&amp; myAttributes = currentFeature.attributeMap();<br>
<br>
<br>
 //get the value from the &quot;Elevation&quot; field<br>
<br>
double zval = //value from field<br>
<br>
<br>
<br>
//add point coordinates to point and add point to dt<br>
<br>
 Point pt = Point(currentPoint.x(), currentPoint.y(), zval);<br>
<br>
dt.insert(pt);<br>
<br>
//delete currentFeature;<br>
<br>
}<br>
<br>
<br>
Thanks,<br>
<br>
<br>
Matt<br>
<br>
</div></div></blockquote></div><br>