Alterando atributos do Layer no Qgis

Uma função muito útil no Qgis é rodar scripts Python, neste caso cito abaixo um script para alterar os atributos de uma layer pelo terminal de scripts Python do Qgis
n
n    layer = iface.activeLayer() #pega o layer atual da tela
n    layer.startEditing() #inicia a edição do layer
n    for f in layer.selectedFeatures(): #recupera as features de cada tupla
n        layer.changeAttributeValue(f.id(),6,’xxxx’) #alterando o atributo da coluna 6 com texto xxx
n    layer.commitChanges() #confirma as alterações
n    print ‘fim’
n
nReferência: Qgis Doc

Post a Comment

Previous Post Next Post