>----Messaggio originale---- >Da: francescobocca...@libero.it >Data: 04/02/2013 9.20 >A: <wonder...@gmail.com> >Ogg: R: Re: Re: [Qgis-developer] R: Re: attributeMap() > >Hi Martin, >this is my code: > > vproviderA = vlayerA.dataProvider() > > allAttrsA = vproviderA.attributeIndexes() #vettore contente tutti >gli indici dei campi > > try: > vproviderA.select(allAttrsA) > except: > vproviderA.getFeatures() > inFeat = QgsFeature() > outFeat = QgsFeature() > inGeom = QgsGeometry() > outGeom = QgsGeometry() > index = vproviderA.fieldNameIndex(field)#this works > features = QGisLayers.features(vlayerA)#from SEXTANTE > nFeat = len(features) > #vettore contenente valori unici del campo scelto > unique = ftools_utils.getUniqueValues(vproviderA, index) > progress_perc=100/nFeat > n = 0 > outID = 0 > for i in unique: > nElement=0 > xPoints = [] > yPoints = [] > first = True > > features = QGisLayers.features(vlayerA) > for inFeat in features: > try: > atMap = inFeat.attributeMap() > idVar = atMap[ index ] > except: > idVar = inFeat [ index ] > >What am i wrong? >Thanks > >Francesco > > >>----Messaggio originale---- >>Da: wonder...@gmail.com >>Data: 04/02/2013 9.05 >>A: "francescobocca...@libero.it"<francescobocca...@libero.it> >>Cc: "Nathan Woodrow"<madman...@gmail.com>, "qgis-developer@lists.osgeo.org" ><qgis-developer@lists.osgeo.org> >>Ogg: Re: Re: [Qgis-developer] R: Re: attributeMap() >> >>On Sun, Feb 3, 2013 at 9:40 PM, francescobocca...@libero.it >><francescobocca...@libero.it> wrote: >>> Hi Nathan, >>> >>> i tired with the name of the field: >>> >>> idVar = inFeat[field] >>> KeyError: 'type' >>> >>> field is the name of field (in this case 'type'). >> >>Both access by index and by field name should work - if not, the >>attribute is probably not loaded. How do you get the feature - what is >>the select() / getFeatures() command? >> >>Martin >> > >
_______________________________________________ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer