qgis.py

Martin Landa, 2017-02-21 11:57 AM

Download (515 Bytes)

 
1
#!/usr/bin/env python
2

    
3
import sys
4
import time
5
from qgis.core import *
6

    
7
composedURI = '/tmp/test-sqlite/p.sqlite|layername=p'
8
layer = QgsVectorLayer(composedURI, 'p', 'ogr')
9
features = layer.getFeatures()
10
fieldID = layer.fieldNameIndex('value')
11

    
12
start = time.time()
13
layer.startEditing()
14
        
15
layer.updateFields()
16

    
17
for feature in features:
18
    featureID = feature.id()
19
    layer.changeAttributeValue(featureID, fieldID, -1)
20
        
21
layer.commitChanges()
22

    
23
print ("Time elapsed: {}".format(time.time() - start))
24

    
25