Skip to content

Commit 386c424

Browse files
committed
Merge algorithm reprojects layers so that all features are
in CRS of first input layer
1 parent 5ba0b5c commit 386c424

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

python/plugins/processing/algs/help/qgis.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,8 @@ qgis:mergevectorlayers: >
314314

315315
If attributes tables are different, the attribute table of the resulting layer will contain the attributes from both input layers.
316316

317+
The layers will all be reprojected to match the coordinate reference system of the first input layer.
318+
317319
qgis:multiparttosingleparts: >
318320
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.
319321

python/plugins/processing/algs/qgis/Merge.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from qgis.PyQt.QtGui import QIcon
3131
from qgis.PyQt.QtCore import QVariant
3232
from qgis.core import (QgsFields,
33+
QgsFeatureRequest,
3334
QgsProcessingUtils,
3435
QgsProcessingParameterMultipleLayers,
3536
QgsProcessingParameterDefinition,
@@ -104,12 +105,13 @@ def processAlgorithm(self, parameters, context, feedback):
104105
fields.append(sfield)
105106

106107
total = 100.0 / totalFeatureCount
108+
dest_crs = layers[0].crs()
107109
(sink, dest_id) = self.parameterAsSink(parameters, self.OUTPUT, context,
108-
fields, layers[0].wkbType(), layers[0].crs())
110+
fields, layers[0].wkbType(), dest_crs)
109111

110112
featureCount = 0
111113
for layer in layers:
112-
for feature in layer.getFeatures():
114+
for feature in layer.getFeatures(QgsFeatureRequest().setDestinationCrs(dest_crs)):
113115
if feedback.isCanceled():
114116
break
115117

0 commit comments

Comments
 (0)