[Qgis-developer] R: Re: attributeMap()

francescoboccacci at libero.it francescoboccacci at libero.it
Sat Feb 2 08:53:35 PST 2013


Hi Martin,
thanks for your answer. I receive another type of error:

"/home/francesco/.qgis//python/plugins/sextante_animove/href.py", line 126, in 
processAlgorithm
    idVar = inFeat[index]
KeyError: '0'

where is the problem?

Thanks

Francesco

>----Messaggio originale----
>Da: wonder.sk at gmail.com
>Data: 02/02/2013 17.33
>A: "francescoboccacci at libero.it"<francescoboccacci at libero.it>
>Cc: "qgis-developer at lists.osgeo.org"<qgis-developer at lists.osgeo.org>
>Ogg: Re: [Qgis-developer] attributeMap()
>
>Hi Francesco
>
>On Sat, Feb 2, 2013 at 4:24 PM, francescoboccacci at libero.it
><francescoboccacci at libero.it> wrote:
>> i have some problem to adapt my old code to new API.
>> i have below piece of code:
>>
>> index = vproviderA.fieldNameIndex(field)
>> atMap = inFeat.attributeMap()
>> idVar = atMap[ index ]
>>
>> to get a value of a this features in a field.
>> Now is it no possbile because QgsFeature hasn't attributeMap().
>
>attributeMap() has been replaced by attributes(), but there's
>additionally an easier way how to access attributes by indices:
>>>> idVar = inFeat[0]
>
>And now there is even easier way for accessing attributes - directly
>by field name:
>>>> idVar = inFeat["name"]
>
>Martin
>




More information about the Qgis-developer mailing list