File tree Expand file tree Collapse file tree 1 file changed +13
-11
lines changed
python/plugins/processing/algs/qgis/scripts Expand file tree Collapse file tree 1 file changed +13
-11
lines changed Original file line number Diff line number Diff line change 1
- ##Vector table tools =group
2
- ##Input =vector
3
- ##Fields =string
4
- ##Output =output table
1
+ ##Table =group
2
+ ##input =vector
3
+ ##fields =string
4
+ ##output =output table
5
5
6
6
from qgis .core import *
7
7
from PyQt4 .QtCore import *
8
+ from processing .core .TableWriter import TableWriter
8
9
from collections import defaultdict
9
10
10
- layer = processing .getObject (Input )
11
+ layer = processing .getObject (input )
11
12
inputFields = layer .pendingFields ()
12
13
fieldIdxs = []
13
- fields = Fields .split (',' )
14
- for f in fields :
15
- idx = inputFields .indexFromName (f )
14
+ fields = fields .split (',' )
15
+ for f in fields :
16
+ idx = inputFields .indexFromName (f )
16
17
if idx == - 1 :
17
18
raise GeoAlgorithmExecutionException ('Field not found:' + f )
18
19
fieldIdxs .append (idx )
19
- writer = processing . TableWriter (Output , None , fields + ['FREQ' ])
20
+ writer = TableWriter (output , None , fields + ['FREQ' ])
20
21
21
22
counts = {}
22
23
feats = processing .features (layer )
23
24
nFeats = len (feats )
24
25
counts = defaultdict (int )
25
26
for i , feat in enumerate (feats ):
26
- progress .setPercentage (int (100 * i / nFeats ))
27
+ progress .setPercentage (int (100 * i / nFeats ))
27
28
attrs = feat .attributes ()
28
29
clazz = tuple ([attrs [idx ] for idx in fieldIdxs ])
30
+ print clazz
29
31
counts [clazz ] += 1
30
32
31
- for c in counts :
33
+ for c in counts :
32
34
writer .addRecord (list (c ) + [counts [c ]])
33
35
You can’t perform that action at this time.
0 commit comments