[Qgis-developer] featureAtId replacement

Denis Rouzaud denis.rouzaud at gmail.com
Mon Feb 11 06:20:54 PST 2013


Hi Martin, hi all,

Having a feature ID, I'd like to get the corresponding feature. Here is 
what I wrote in python:

         freq = QgsFeatureRequest()
         freq.setFilterFid(myID)
         features = []
         for f in layer.getFeatures( freq ):
             features.append( f )
         if len( features ) != 0:
            return features[0]

which quite heavier than the previous

f = QgsFeature
if layer.featureAtId(self.subset[i],f):
    return f


Is there anything I missed? Anything lighter to write?

Thanks a lot,

Denis






More information about the Qgis-developer mailing list