Skip to content
Permalink
Browse files

Fix grass alg combineLayerExtents

  • Loading branch information
elpaso authored and nyalldawson committed Apr 12, 2019
1 parent bdd7a1c commit 0d7841a0d8ea57891f46c91e02e95ce12714930f
Showing with 7 additions and 1 deletion.
  1. +7 −1 python/plugins/processing/algs/grass7/Grass7Algorithm.py
@@ -37,6 +37,7 @@
QgsRasterLayer,
QgsApplication,
QgsMapLayerType,
QgsCoordinateReferenceSystem,
QgsProcessingUtils,
QgsProcessing,
QgsMessageLog,
@@ -127,6 +128,9 @@ def __init__(self, descriptionfile):
self.minArea = None
self.alignToResolution = None

# destination Crs for combineLayerExtents, will be set from layer or mapSettings
self.destination_crs = QgsCoordinateReferenceSystem()

# Load parameters from a description file
self.defineCharacteristicsFromFile()
self.numExportedLayers = 0
@@ -500,7 +504,7 @@ def postInputs(self, context):

# Build GRASS region
if self.region.isEmpty():
self.region = QgsProcessingUtils.combineLayerExtents(self.inputLayers, context)
self.region = QgsProcessingUtils.combineLayerExtents(self.inputLayers, self.destination_crs, context)
command = 'g.region n={} s={} e={} w={}'.format(
self.region.yMaximum(), self.region.yMinimum(),
self.region.xMaximum(), self.region.xMinimum()
@@ -1001,6 +1005,7 @@ def setSessionProjectionFromProject(self):
We creates a PROJ4 definition which is transmitted to Grass
"""
if not Grass7Utils.projectionSet and iface:
self.destination_crs = iface.mapCanvas().mapSettings().destinationCrs()
proj4 = iface.mapCanvas().mapSettings().destinationCrs().toProj4()
command = 'g.proj -c proj4="{}"'.format(proj4)
self.commands.append(command)
@@ -1013,6 +1018,7 @@ def setSessionProjectionFromLayer(self, layer):
"""
if not Grass7Utils.projectionSet:
proj4 = str(layer.crs().toProj4())
self.destination_crs = layer.crs()
command = 'g.proj -c proj4="{}"'.format(proj4)
self.commands.append(command)
Grass7Utils.projectionSet = True

0 comments on commit 0d7841a

Please sign in to comment.
You can’t perform that action at this time.