QGIS-2.8-PyQGISDeveloperCookbook-en(20)
时间:2025-03-11
时间:2025-03-11
为开发人员准备的文档,涵盖QGIS的多种功能实现和代码。
tohaveaQgsVectorLayerobject
5.3.1Accessingattributes
Attributescanbereferredtobytheir
name.
Alternatively,attributescanbereferredtobyindex.Thisiswillbeabitfasterthanusingthename.Forexample,
togetthe rstattribute:
5.3.2Iteratingoverselectedfeatures
ifyouonlyneedselectedfeatures,youcanusetheselectedFeatures()methodfromvectorlayer:
AnotheroptionistheProcessingfeatures()method:
Bydefault,thiswilliterateoverallthefeaturesinthelayer,incasethereisnoselection,orovertheselected
featuresotherwise.NotethatthisbehaviorcanbechangedintheProcessingoptionstoignoreselections.