2014-11-30 10:26:17 +01:00
|
|
|
##Iterate over the features of a layer.
|
2014-11-21 15:01:23 +01:00
|
|
|
feats = processing.features(layer)
|
|
|
|
n = len(feats)
|
|
|
|
for i, feat in enumerate(feats):
|
|
|
|
progress.setPercentage(int(100 * i / n))
|
|
|
|
#do something with 'feat'
|
|
|
|
|
|
|
|
##Create a new layer from another one, with an extra field
|
|
|
|
fields = processing.fields(layer)
|
|
|
|
# int, float and bool can be used as well as types
|
|
|
|
fields.append(('NEW_FIELD', str))
|
2014-11-30 10:26:17 +01:00
|
|
|
writer = processing.VectorWriter(output_file, None, fields,
|
fix python pep8 warnings and fix some revealed errors
pep8 --ignore=E111,E128,E201,E202,E203,E211,E221,E222,E225,E226,E227,E231,E241,E261,E265,E272,E302,E303,E501,E701 \
--exclude="ui_*.py,debian/*,python/ext-libs/*" \
.
2015-02-01 14:15:42 +01:00
|
|
|
processing.geomtype(layer), layer.crs()
|
|
|
|
)
|
2014-11-21 15:01:23 +01:00
|
|
|
|
|
|
|
##Create a new table
|
fix python pep8 warnings and fix some revealed errors
pep8 --ignore=E111,E128,E201,E202,E203,E211,E221,E222,E225,E226,E227,E231,E241,E261,E265,E272,E302,E303,E501,E701 \
--exclude="ui_*.py,debian/*,python/ext-libs/*" \
.
2015-02-01 14:15:42 +01:00
|
|
|
writer = processing.TableWriter(output_file, None, ['field1', 'field2'])
|