Skip to content

Commit

Permalink
Merge algorithm reprojects layers so that all features are
Browse files Browse the repository at this point in the history
in CRS of first input layer
  • Loading branch information
nyalldawson committed Jun 11, 2017
1 parent 5ba0b5c commit 386c424
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions python/plugins/processing/algs/help/qgis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
6 changes: 4 additions & 2 deletions python/plugins/processing/algs/qgis/Merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from qgis.PyQt.QtGui import QIcon
from qgis.PyQt.QtCore import QVariant
from qgis.core import (QgsFields,
QgsFeatureRequest,
QgsProcessingUtils,
QgsProcessingParameterMultipleLayers,
QgsProcessingParameterDefinition,
Expand Down Expand Up @@ -104,12 +105,13 @@ def processAlgorithm(self, parameters, context, feedback):
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

Expand Down

0 comments on commit 386c424

Please sign in to comment.