Skip to content

Commit 6129ea5

Browse files
author
brushtyler
committed
fixed #3449 making sure the clipping result has the layers order as in TOC
git-svn-id: http://svn.osgeo.org/qgis/trunk@15125 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 136077c commit 6129ea5

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

python/plugins/GdalTools/tools/doClipper.py

+16-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ def onClosing(self):
5353
def fillInputFiles(self):
5454
self.inputFiles = QStringList()
5555

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):
5860
layer = self.canvas.layer(i)
5961
# only raster layers, but not WMS ones
6062
if layer.type() == layer.RasterLayer and ( not layer.usesProvider() ):
@@ -70,6 +72,9 @@ def fillInputFiles(self):
7072
if self.isVisible() and self.warningDialog.isHidden():
7173
msg = QString( self.tr("No active raster layers. You must add almost one raster layer to continue.") )
7274
self.warningDialog.showMessage(msg)
75+
76+
# refresh command when there are no active layers
77+
self.someValueChanged()
7378
else:
7479
self.warningDialog.hide()
7580
self.extentSelector.start()
@@ -114,6 +119,15 @@ def getArguments(self):
114119
if not self.outputFileEdit.text().isEmpty():
115120
arguments << "-o"
116121
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+
117131
arguments << self.inputFiles
118132
return arguments
119133

0 commit comments

Comments
 (0)