Skip to content

Commit ac54c8e

Browse files
committedOct 3, 2014
[processing] updated freq analysis alg
1 parent 558765a commit ac54c8e

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed
 
Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,35 @@
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
55

66
from qgis.core import *
77
from PyQt4.QtCore import *
8+
from processing.core.TableWriter import TableWriter
89
from collections import defaultdict
910

10-
layer = processing.getObject(Input)
11+
layer = processing.getObject(input)
1112
inputFields = layer.pendingFields()
1213
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)
1617
if idx == -1:
1718
raise GeoAlgorithmExecutionException('Field not found:' + f)
1819
fieldIdxs.append(idx)
19-
writer = processing.TableWriter(Output, None, fields + ['FREQ'])
20+
writer = TableWriter(output, None, fields + ['FREQ'])
2021

2122
counts = {}
2223
feats = processing.features(layer)
2324
nFeats = len(feats)
2425
counts = defaultdict(int)
2526
for i, feat in enumerate(feats):
26-
progress.setPercentage(int(100 * i / nFeats))
27+
progress.setPercentage(int(100 * i / nFeats))
2728
attrs = feat.attributes()
2829
clazz = tuple([attrs[idx] for idx in fieldIdxs])
30+
print clazz
2931
counts[clazz] += 1
3032

31-
for c in counts:
33+
for c in counts:
3234
writer.addRecord(list(c) + [counts[c]])
3335

0 commit comments

Comments
 (0)
Please sign in to comment.