37
37
QgsRasterLayer ,
38
38
QgsApplication ,
39
39
QgsMapLayerType ,
40
+ QgsCoordinateReferenceSystem ,
40
41
QgsProcessingUtils ,
41
42
QgsProcessing ,
42
43
QgsMessageLog ,
@@ -127,6 +128,9 @@ def __init__(self, descriptionfile):
127
128
self .minArea = None
128
129
self .alignToResolution = None
129
130
131
+ # destination Crs for combineLayerExtents, will be set from layer or mapSettings
132
+ self .destination_crs = QgsCoordinateReferenceSystem ()
133
+
130
134
# Load parameters from a description file
131
135
self .defineCharacteristicsFromFile ()
132
136
self .numExportedLayers = 0
@@ -500,7 +504,7 @@ def postInputs(self, context):
500
504
501
505
# Build GRASS region
502
506
if self .region .isEmpty ():
503
- self .region = QgsProcessingUtils .combineLayerExtents (self .inputLayers , context )
507
+ self .region = QgsProcessingUtils .combineLayerExtents (self .inputLayers , self . destination_crs , context )
504
508
command = 'g.region n={} s={} e={} w={}' .format (
505
509
self .region .yMaximum (), self .region .yMinimum (),
506
510
self .region .xMaximum (), self .region .xMinimum ()
@@ -1001,6 +1005,7 @@ def setSessionProjectionFromProject(self):
1001
1005
We creates a PROJ4 definition which is transmitted to Grass
1002
1006
"""
1003
1007
if not Grass7Utils .projectionSet and iface :
1008
+ self .destination_crs = iface .mapCanvas ().mapSettings ().destinationCrs ()
1004
1009
proj4 = iface .mapCanvas ().mapSettings ().destinationCrs ().toProj4 ()
1005
1010
command = 'g.proj -c proj4="{}"' .format (proj4 )
1006
1011
self .commands .append (command )
@@ -1013,6 +1018,7 @@ def setSessionProjectionFromLayer(self, layer):
1013
1018
"""
1014
1019
if not Grass7Utils .projectionSet :
1015
1020
proj4 = str (layer .crs ().toProj4 ())
1021
+ self .destination_crs = layer .crs ()
1016
1022
command = 'g.proj -c proj4="{}"' .format (proj4 )
1017
1023
self .commands .append (command )
1018
1024
Grass7Utils .projectionSet = True
0 commit comments