-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed some minor bugs in sextante algs
Removed SAGA Split algorithms
- Loading branch information
Showing
15 changed files
with
90 additions
and
52 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
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
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
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
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
8 changes: 0 additions & 8 deletions
8
python/plugins/sextante/saga/description/SplitShapesLayer.txt
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
python/plugins/sextante/saga/description/SplitShapesLayerCompletely.txt
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
python/plugins/sextante/saga/description/SplitShapesbyAttribute.txt
This file was deleted.
Oops, something went wrong.
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
50 changes: 50 additions & 0 deletions
50
python/plugins/sextante/script/scripts/Split_vector_layer_by_attribute.py
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,50 @@ | ||
#Definition of inputs and outputs | ||
#================================== | ||
##[Example scripts]=group | ||
##input=vector | ||
##class_field=field input | ||
##output=output file | ||
|
||
#Algorithm body | ||
#================================== | ||
from sextante.core.QGisLayers import QGisLayers | ||
from qgis.core import * | ||
from PyQt4.QtCore import * | ||
from sextante.core.SextanteVectorWriter import SextanteVectorWriter | ||
|
||
# "input" contains the location of the selected layer. | ||
# We get the actual object, | ||
layer = QGisLayers.getObjectFromUri(input) | ||
provider = layer.dataProvider() | ||
allAttrs = provider.attributeIndexes() | ||
provider.select( allAttrs ) | ||
fields = provider.fields() | ||
writers = {} | ||
|
||
# Fields are defined by their names, but QGIS needs the index for the attributes map | ||
class_field_index = provider.fieldNameIndex(class_field) | ||
|
||
inFeat = QgsFeature() | ||
outFeat = QgsFeature() | ||
inGeom = QgsGeometry() | ||
nFeat = provider.featureCount() | ||
nElement = 0 | ||
writers = {} | ||
|
||
while provider.nextFeature(inFeat): | ||
progress.setPercentage(int((100 * nElement)/nFeat)) | ||
nElement += 1 | ||
atMap = inFeat.attributeMap() | ||
clazz = atMap[class_field_index].toString() | ||
if clazz not in writers: | ||
outputFile = output + "_" + str(len(writers)) + ".shp" | ||
writers[clazz] = SextanteVectorWriter(outputFile, None, fields, provider.geometryType(), provider.crs() ) | ||
inGeom = inFeat.geometry() | ||
outFeat.setGeometry(inGeom) | ||
outFeat.setAttributeMap(atMap) | ||
writers[clazz].addFeature(outFeat) | ||
|
||
|
||
|
||
for writer in writers.values(): | ||
del writer |