@@ -53,8 +53,10 @@ def onClosing(self):
53
53
def fillInputFiles (self ):
54
54
self .inputFiles = QStringList ()
55
55
56
- # for each active layer
57
- for i in range (self .canvas .layerCount ()):
56
+ # Reversed list to have the topmost layer as the last one in the list
57
+ # because "In areas of overlap, the last image will be copied over
58
+ # earlier ones" (see http://www.gdal.org/gdal_merge.html).
59
+ for i in range (self .canvas .layerCount ()- 1 , - 1 , - 1 ):
58
60
layer = self .canvas .layer (i )
59
61
# only raster layers, but not WMS ones
60
62
if layer .type () == layer .RasterLayer and ( not layer .usesProvider () ):
@@ -70,6 +72,9 @@ def fillInputFiles(self):
70
72
if self .isVisible () and self .warningDialog .isHidden ():
71
73
msg = QString ( self .tr ("No active raster layers. You must add almost one raster layer to continue." ) )
72
74
self .warningDialog .showMessage (msg )
75
+
76
+ # refresh command when there are no active layers
77
+ self .someValueChanged ()
73
78
else :
74
79
self .warningDialog .hide ()
75
80
self .extentSelector .start ()
@@ -114,6 +119,15 @@ def getArguments(self):
114
119
if not self .outputFileEdit .text ().isEmpty ():
115
120
arguments << "-o"
116
121
arguments << self .outputFileEdit .text ()
122
+
123
+ if self .pctCheck .isChecked () and len (self .inputFiles ) > 1 :
124
+ # The topmost layer in the TOC is the last one in the list (see above),
125
+ # but I want to grab the pseudocolor table from the first image (the
126
+ # topmost layer in the TOC).
127
+ # Workaround: duplicate the last layer inserting it also as the first
128
+ # one to grab the pseudocolor table from it.
129
+ arguments << self .inputFiles [ len (self .inputFiles )- 1 ]
130
+
117
131
arguments << self .inputFiles
118
132
return arguments
119
133
0 commit comments