layermap = QgsMapLayerRegistry.instance().mapLayers()
for (name,layer) in layermap.iteritems():
if layer.type() != QgsVectorLayer.VectorLayer:
continue
if "SampleLayer" in layer.name():
dP = layer.dataProvider()
for attr in dP.fields():
if (attr.name() == "SampleAttr"):
SampleAttrId = dP.fieldNameIndex(attr.name())
break
layer.select(dP.attributeIndexes())
FetSet = layer.getFeatures()
for feat in FetSet:
SampleAttrStr = str(feat[SampleAttrId])
SampleAttrValue = float(str(feat[SampleAttrId]))
沒有留言:
張貼留言