Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[processing] Add snippet collection to script editor
The list of snippets is still very short, but the snippet management logic is added in this commit
- Loading branch information
Showing
3 changed files
with
67 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
##Iterate over the features of a layer. | ||
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)) | ||
writer = processing.VectorWriter(output_file, None, fields, | ||
processing.geomtype(layer), layer.crs()) | ||
|
||
##Create a new table | ||
writer = processing.TableWriter(output_file, None, ['field1', 'field2']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters