Merge algorithm reprojects layers so that all features are

in CRS of first input layer
This commit is contained in:
Nyall Dawson 2017-06-09 15:51:14 +10:00
parent 5ba0b5cd83
commit 386c4246b2
2 changed files with 6 additions and 2 deletions

View File

@ -314,6 +314,8 @@ qgis:mergevectorlayers: >
If attributes tables are different, the attribute table of the resulting layer will contain the attributes from both input layers.
The layers will all be reprojected to match the coordinate reference system of the first input layer.
qgis:multiparttosingleparts: >
This algorithm takes a vector layer with multipart geometries and generates a new one in which all geometries contain a single part. Features with multipart geometries are divided in as many different features as parts the geometry contain, and the same attributes are used for each of them.

View File

@ -30,6 +30,7 @@ import os
from qgis.PyQt.QtGui import QIcon
from qgis.PyQt.QtCore import QVariant
from qgis.core import (QgsFields,
QgsFeatureRequest,
QgsProcessingUtils,
QgsProcessingParameterMultipleLayers,
QgsProcessingParameterDefinition,
@ -104,12 +105,13 @@ class Merge(QgisAlgorithm):
fields.append(sfield)
total = 100.0 / totalFeatureCount
dest_crs = layers[0].crs()
(sink, dest_id) = self.parameterAsSink(parameters, self.OUTPUT, context,
fields, layers[0].wkbType(), layers[0].crs())
fields, layers[0].wkbType(), dest_crs)
featureCount = 0
for layer in layers:
for feature in layer.getFeatures():
for feature in layer.getFeatures(QgsFeatureRequest().setDestinationCrs(dest_crs)):
if feedback.isCanceled():
break