Exemple #1
0
 def useLayerExtent(self):
     CANVAS_KEY = "Use canvas extent"
     extentsDict = {}
     extentsDict[CANVAS_KEY] = {
         "extent": iface.mapCanvas().extent(),
         "authid": iface.mapCanvas().mapSettings().destinationCrs().authid(),
     }
     extents = [CANVAS_KEY]
     layers = dataobjects.getAllLayers()
     for layer in layers:
         authid = layer.crs().authid()
         if ProcessingConfig.getSetting(ProcessingConfig.SHOW_CRS_DEF) and authid is not None:
             layerName = u"{} [{}]".format(layer.name(), authid)
         else:
             layerName = layer.name()
         extents.append(layerName)
         extentsDict[layerName] = {"extent": layer.extent(), "authid": authid}
     (item, ok) = QInputDialog.getItem(self, self.tr("Select extent"), self.tr("Use extent from"), extents, False)
     if ok:
         self.setValueFromRect(extentsDict[item]["extent"])
         if extentsDict[item]["authid"] != iface.mapCanvas().mapSettings().destinationCrs().authid():
             iface.messageBar().pushMessage(
                 self.tr("Warning"),
                 self.tr(
                     "The projection of the chosen layer is not the same as canvas projection! The selected extent might not be what was intended."
                 ),
                 QgsMessageBar.WARNING,
                 8,
             )
Exemple #2
0
 def setOutputCRS(self):
     layers = dataobjects.getAllLayers()
     for param in self.parameters:
         if isinstance(param, (ParameterRaster, ParameterVector,
                       ParameterMultipleInput)):
             if param.value:
                 inputlayers = param.value.split(';')
                 for inputlayer in inputlayers:
                     for layer in layers:
                         if layer.source() == inputlayer:
                             self.crs = layer.crs()
                             return
                     if isinstance(param, ParameterRaster) \
                             or isinstance(param, ParameterMultipleInput) \
                             and param.datatype \
                             == ParameterMultipleInput.TYPE_RASTER:
                         p = QgsProviderRegistry.instance().provider('gdal',
                                 inputlayer)
                     else:
                         p = QgsProviderRegistry.instance().provider('ogr',
                                 inputlayer)
                     if p is not None:
                         self.crs = p.crs()
                         return
     try:
         from qgis.utils import iface
         self.crs = iface.mapCanvas().mapRenderer().destinationCrs()
     except:
         pass
Exemple #3
0
 def setOutputCRS(self):
     layers = dataobjects.getAllLayers()
     for param in self.parameters:
         if isinstance(param, (ParameterRaster, ParameterVector, ParameterMultipleInput)):
             if param.value:
                 if isinstance(param, ParameterMultipleInput):
                     inputlayers = param.value.split(';')
                 else:
                     inputlayers = [param.value]
                 for inputlayer in inputlayers:
                     for layer in layers:
                         if layer.source() == inputlayer:
                             self.crs = layer.crs()
                             return
                     p = dataobjects.getObjectFromUri(inputlayer)
                     if p is not None:
                         self.crs = p.crs()
                         p = None
                         return
     try:
         from qgis.utils import iface
         if iface is not None:
             self.crs = iface.mapCanvas().mapSettings().destinationCrs()
     except:
         pass
Exemple #4
0
 def setOutputCRS(self):
     layers = dataobjects.getAllLayers()
     for param in self.parameters:
         if isinstance(param, (ParameterRaster, ParameterVector,
                       ParameterMultipleInput)):
             if param.value:
                 inputlayers = param.value.split(';')
                 for inputlayer in inputlayers:
                     for layer in layers:
                         if layer.source() == inputlayer:
                             self.crs = layer.crs()
                             return
                     if isinstance(param, ParameterRaster) \
                             or isinstance(param, ParameterMultipleInput) \
                             and param.datatype \
                             == ParameterMultipleInput.TYPE_RASTER:
                         p = QgsProviderRegistry.instance().provider('gdal',
                                 inputlayer)
                     else:
                         p = QgsProviderRegistry.instance().provider('ogr',
                                 inputlayer)
                     if p is not None:
                         self.crs = p.crs()
                         return
     qgis = dataobjects.interface.iface
     self.crs = qgis.mapCanvas().mapRenderer().destinationCrs()
Exemple #5
0
    def checkExtentCRS(self):
        unmatchingCRS = False
        hasExtent = False
        projectCRS = iface.mapCanvas().mapSettings().destinationCrs()
        layers = dataobjects.getAllLayers()
        for param in self.alg.parameters:
            if isinstance(param, (ParameterRaster, ParameterVector, ParameterMultipleInput)):
                if param.value:
                    if isinstance(param, ParameterMultipleInput):
                        inputlayers = param.value.split(';')
                    else:
                        inputlayers = [param.value]
                    for inputlayer in inputlayers:
                        for layer in layers:
                            if layer.source() == inputlayer:
                                if layer.crs() != projectCRS:
                                    unmatchingCRS = True

                        p = dataobjects.getObjectFromUri(inputlayer)
                        if p is not None:
                            if p.crs() != projectCRS:
                                unmatchingCRS = True
            if isinstance(param, ParameterExtent):
                value = self.mainWidget.wrappers[param.name].widget.leText.text().strip()
                if value:
                    hasExtent = True

        return hasExtent and unmatchingCRS
Exemple #6
0
 def useLayerExtent(self):
     CANVAS_KEY = 'Use canvas extent'
     extentsDict = {}
     extentsDict[CANVAS_KEY] = {
         "extent": iface.mapCanvas().extent(),
         "authid":
         iface.mapCanvas().mapRenderer().destinationCrs().authid()
     }
     extents = [CANVAS_KEY]
     layers = dataobjects.getAllLayers()
     for layer in layers:
         authid = layer.crs().authid()
         if ProcessingConfig.getSetting(ProcessingConfig.SHOW_CRS_DEF) \
                 and authid is not None:
             layerName = u'{} [{}]'.format(layer.name(), authid)
         else:
             layerName = layer.name()
         extents.append(layerName)
         extentsDict[layerName] = {
             "extent": layer.extent(),
             "authid": authid
         }
     (item, ok) = QInputDialog.getItem(self, self.tr('Select extent'),
                                       self.tr('Use extent from'), extents,
                                       False)
     if ok:
         self.setValueFromRect(extentsDict[item]["extent"])
         if extentsDict[item]["authid"] != iface.mapCanvas().mapRenderer(
         ).destinationCrs().authid():
             iface.messageBar().pushMessage(
                 self.tr("Warning"),
                 self.
                 tr("The projection of the chosen layer is not the same as canvas projection! The selected extent might not be what was intended."
                    ), QgsMessageBar.WARNING, 8)
Exemple #7
0
 def setOutputCRS(self):
     layers = dataobjects.getAllLayers()
     for param in self.parameters:
         if isinstance(
                 param,
             (ParameterRaster, ParameterVector, ParameterMultipleInput)):
             if param.value:
                 if isinstance(param, ParameterMultipleInput):
                     inputlayers = param.value.split(';')
                 else:
                     inputlayers = [param.value]
                 for inputlayer in inputlayers:
                     for layer in layers:
                         if layer.source() == inputlayer:
                             self.crs = layer.crs()
                             return
                     p = dataobjects.getObjectFromUri(inputlayer)
                     if p is not None:
                         self.crs = p.crs()
                         p = None
                         return
     try:
         from qgis.utils import iface
         self.crs = iface.mapCanvas().mapRenderer().destinationCrs()
     except:
         pass
Exemple #8
0
    def checkExtentCRS(self):
        unmatchingCRS = False
        hasExtent = False
        projectCRS = iface.mapCanvas().mapSettings().destinationCrs()
        layers = dataobjects.getAllLayers()
        for param in self.alg.parameters:
            if isinstance(
                    param,
                (ParameterRaster, ParameterVector, ParameterMultipleInput)):
                if param.value:
                    if isinstance(param, ParameterMultipleInput):
                        inputlayers = param.value.split(';')
                    else:
                        inputlayers = [param.value]
                    for inputlayer in inputlayers:
                        for layer in layers:
                            if layer.source() == inputlayer:
                                if layer.crs() != projectCRS:
                                    unmatchingCRS = True

                        p = dataobjects.getObjectFromUri(inputlayer)
                        if p is not None:
                            if p.crs() != projectCRS:
                                unmatchingCRS = True
            if isinstance(param, ParameterExtent):
                if param.skip_crs_check:
                    continue

                value = self.mainWidget.wrappers[
                    param.name].widget.leText.text().strip()
                if value:
                    hasExtent = True

        return hasExtent and unmatchingCRS
 def setOutputCRS(self):
     layers = dataobjects.getAllLayers()
     for param in self.parameters:
         if isinstance(param, (ParameterRaster, ParameterVector, ParameterMultipleInput)):
             if param.value:
                 inputlayers = param.value.split(";")
                 for inputlayer in inputlayers:
                     for layer in layers:
                         if layer.source() == inputlayer:
                             self.crs = layer.crs()
                             return
                     if (
                         isinstance(param, ParameterRaster)
                         or isinstance(param, ParameterMultipleInput)
                         and param.datatype == ParameterMultipleInput.TYPE_RASTER
                     ):
                         p = QgsProviderRegistry.instance().provider("gdal", inputlayer)
                     else:
                         p = QgsProviderRegistry.instance().provider("ogr", inputlayer)
                     if p is not None:
                         self.crs = p.crs()
                         return
     qgis = dataobjects.interface.iface
     if qgis is None:
         return
     self.crs = qgis.mapCanvas().mapRenderer().destinationCrs()
 def useLayerExtent(self):
     CANVAS_KEY = "Use canvas extent"
     extentsDict = {}
     extentsDict[CANVAS_KEY] = iface.mapCanvas().extent()
     extents = [CANVAS_KEY]
     layers = dataobjects.getAllLayers()
     for layer in layers:
         extents.append(layer.name())
         extentsDict[layer.name()] = layer.extent()
     (item, ok) = QInputDialog.getItem(self, self.tr("Select extent"), self.tr("Use extent from"), extents, False)
     if ok:
         self.setValueFromRect(extentsDict[item])
Exemple #11
0
    def fillTree(self):
        layersItem = QtGui.QTreeWidgetItem()
        layersItem.setText(0, "Values from data layers extents")
        self.tree.addTopLevelItem(layersItem)
        layers = dataobjects.getAllLayers()
        for layer in layers:
            layerItem = QtGui.QTreeWidgetItem()
            layerItem.setText(0, unicode(layer.name()))
            layerItem.addChild(TreeValueItem("Min X", layer.extent().xMinimum()))
            layerItem.addChild(TreeValueItem("Max X", layer.extent().xMaximum()))
            layerItem.addChild(TreeValueItem("Min Y", layer.extent().yMinimum()))
            layerItem.addChild(TreeValueItem("Max y", layer.extent().yMaximum()))
            if isinstance(layer, QgsRasterLayer):
                cellsize = (layer.extent().xMaximum() - layer.extent().xMinimum())/layer.width()
                layerItem.addChild(TreeValueItem("Cellsize", cellsize))
            layersItem.addChild(layerItem)
        layersItem = QtGui.QTreeWidgetItem()
        layersItem.setText(0, "Values from raster layers statistics")
        self.tree.addTopLevelItem(layersItem)
        layers = dataobjects.getRasterLayers()
        for layer in layers:
            for i in range(layer.bandCount()):
                if QGis.QGIS_VERSION_INT >= 10900:
                    stats = layer.dataProvider().bandStatistics(i+1)
                else:
                    stats = layer.bandStatistics(i)
                layerItem = QtGui.QTreeWidgetItem()
                layerItem.setText(0, unicode(layer.name()))
                layerItem.addChild(TreeValueItem("Mean", stats.mean))
                layerItem.addChild(TreeValueItem("Std. deviation", stats.stdDev))
                layerItem.addChild(TreeValueItem("Max value", stats.maximumValue))
                layerItem.addChild(TreeValueItem("Min value", stats.minimumValue))
                layersItem.addChild(layerItem)

        canvasItem = QtGui.QTreeWidgetItem()
        canvasItem.setText(0, "Values from QGIS map canvas")
        self.tree.addTopLevelItem(canvasItem)
        extent = interface.iface.mapCanvas().extent()
        extentItem  = QtGui.QTreeWidgetItem()
        extentItem.setText(0, "Current extent")
        extentItem.addChild(TreeValueItem("Min X", extent.xMinimum()))
        extentItem.addChild(TreeValueItem("Max X", extent.xMaximum()))
        extentItem.addChild(TreeValueItem("Min Y", extent.yMinimum()))
        extentItem.addChild(TreeValueItem("Max y", extent.yMaximum()))
        canvasItem.addChild(extentItem)
        extent = interface.iface.mapCanvas().fullExtent()
        extentItem  = QtGui.QTreeWidgetItem()
        extentItem.setText(0, "Full extent of all layers in map canvas")
        extentItem.addChild(TreeValueItem("Min X", extent.xMinimum()))
        extentItem.addChild(TreeValueItem("Max X", extent.xMaximum()))
        extentItem.addChild(TreeValueItem("Min Y", extent.yMinimum()))
        extentItem.addChild(TreeValueItem("Max y", extent.yMaximum()))
        canvasItem.addChild(extentItem)
 def useLayerExtent(self):
     CANVAS_KEY = 'Use canvas extent'
     extentsDict = {}
     extentsDict[CANVAS_KEY] = iface.mapCanvas().extent()
     extents = [CANVAS_KEY]
     layers = dataobjects.getAllLayers()
     for layer in layers:
         extents.append(layer.name())
         extentsDict[layer.name()] = layer.extent()
     (item, ok) = QInputDialog.getItem(self, self.tr('Select extent'),
             self.tr('Use extent from'), extents, False)
     if ok:
         self.setValueFromRect(extentsDict[item])
Exemple #13
0
 def resolveDataObjects(self):
     layers = dataobjects.getAllLayers()
     for param in self.parameters:
         if isinstance(param, (ParameterRaster, ParameterVector, ParameterTable, ParameterMultipleInput)):
             if param.value:
                 if isinstance(param, ParameterMultipleInput):
                     inputlayers = param.value.split(";")
                 else:
                     inputlayers = [param.value]
                 for i, inputlayer in enumerate(inputlayers):
                     for layer in layers:
                         if layer.name() == inputlayer:
                             inputlayers[i] = layer.source()
                             break
                 param.setValue(";".join(inputlayers))
Exemple #14
0
 def useLayerExtent(self):
     CANVAS_KEY = 'Use canvas extent'
     extentsDict = {}
     extentsDict[CANVAS_KEY] = {"extent": iface.mapCanvas().extent(),
                                "authid": iface.mapCanvas().mapSettings().destinationCrs().authid()}
     extents = [CANVAS_KEY]
     layers = dataobjects.getAllLayers()
     for layer in layers:
         authid = layer.crs().authid()
         layerName = layer.name()
         extents.append(layerName)
         extentsDict[layerName] = {"extent": layer.extent(), "authid": authid}
     (item, ok) = QInputDialog.getItem(self, self.tr('Select extent'),
                                       self.tr('Use extent from'), extents, False)
     if ok:
         self.setValue(extentsDict[item]["extent"], extentsDict[item]['authid'])
Exemple #15
0
 def resolveDataObjects(self):
     layers = dataobjects.getAllLayers()
     for param in self.parameters:
         if isinstance(param, (ParameterRaster, ParameterVector,
                               ParameterTable, ParameterMultipleInput)):
             if param.value:
                 if isinstance(param, ParameterMultipleInput):
                     inputlayers = param.value.split(';')
                 else:
                     inputlayers = [param.value]
                 for i, inputlayer in enumerate(inputlayers):
                     for layer in layers:
                         if layer.name() == inputlayer:
                             inputlayers[i] = layer.source()
                             break
                 param.setValue(";".join(inputlayers))
    def expressionContext(self):
        context = QgsExpressionContext()
        context.appendScope(QgsExpressionContextUtils.globalScope())
        context.appendScope(QgsExpressionContextUtils.projectScope())
        processingScope = QgsExpressionContextScope()
        layers = dataobjects.getAllLayers()
        for layer in layers:
            name = layer.name()
            processingScope.setVariable('%s_minx' % name,
                                        layer.extent().xMinimum())
            processingScope.setVariable('%s_miny' % name,
                                        layer.extent().yMinimum())
            processingScope.setVariable('%s_maxx' % name,
                                        layer.extent().xMaximum())
            processingScope.setVariable('%s_maxy' % name,
                                        layer.extent().yMaximum())
            if isinstance(layer, QgsRasterLayer):
                cellsize = (layer.extent().xMaximum() -
                            layer.extent().xMinimum()) / layer.width()
                processingScope.setVariable('%s_cellsize' % name, cellsize)

        layers = dataobjects.getRasterLayers()
        for layer in layers:
            for i in range(layer.bandCount()):
                stats = layer.dataProvider().bandStatistics(i + 1)
                processingScope.setVariable('%s_band%i_avg' % (name, i + 1),
                                            stats.mean)
                processingScope.setVariable('%s_band%i_stddev' % (name, i + 1),
                                            stats.stdDev)
                processingScope.setVariable('%s_band%i_min' % (name, i + 1),
                                            stats.minimumValue)
                processingScope.setVariable('%s_band%i_max' % (name, i + 1),
                                            stats.maximumValue)

        extent = iface.mapCanvas().extent()
        processingScope.setVariable('canvasextent_minx', extent.xMinimum())
        processingScope.setVariable('canvasextent_miny', extent.yMinimum())
        processingScope.setVariable('canvasextent_maxx', extent.xMaximum())
        processingScope.setVariable('canvasextent_maxy', extent.yMaximum())

        extent = iface.mapCanvas().fullExtent()
        processingScope.setVariable('fullextent_minx', extent.xMinimum())
        processingScope.setVariable('fullextent_miny', extent.yMinimum())
        processingScope.setVariable('fullextent_maxx', extent.xMaximum())
        processingScope.setVariable('fullextent_maxy', extent.yMaximum())
        context.appendScope(processingScope)
        return context
Exemple #17
0
 def checkInputCRS(self):
     '''it checks that all input layers use the same CRS. If so, returns True. False otherwise'''
     crs = None;
     layers = dataobjects.getAllLayers()
     for param in self.parameters:
         if isinstance(param, (ParameterRaster, ParameterVector, ParameterMultipleInput)):
             if param.value:
                 inputlayers = param.value.split(";")
                 for inputlayer in inputlayers:
                     for layer in layers:
                         if layer.source() == inputlayer:
                             if crs is None:
                                 crs = layer.crs()
                             else:
                                 if crs != layer.crs():
                                     return False
     return True
Exemple #18
0
 def checkInputCRS(self):
     """It checks that all input layers use the same CRS. If so,
     returns True. False otherwise.
     """
     crs = None
     layers = dataobjects.getAllLayers()
     for param in self.parameters:
         if isinstance(param, (ParameterRaster, ParameterVector,
                       ParameterMultipleInput)):
             if param.value:
                 inputlayers = param.value.split(';')
                 for inputlayer in inputlayers:
                     for layer in layers:
                         if layer.source() == inputlayer:
                             if crs is None:
                                 crs = layer.crs()
                             else:
                                 if crs != layer.crs():
                                     return False
     return True
Exemple #19
0
    def expressionContext(self):
        context = QgsExpressionContext()
        context.appendScope(QgsExpressionContextUtils.globalScope())
        context.appendScope(QgsExpressionContextUtils.projectScope())
        processingScope = QgsExpressionContextScope()
        layers = dataobjects.getAllLayers()
        for layer in layers:
            name = layer.name()
            processingScope.setVariable('%s_minx' % name, layer.extent().xMinimum())
            processingScope.setVariable('%s_miny' % name, layer.extent().yMinimum())
            processingScope.setVariable('%s_maxx' % name, layer.extent().xMaximum())
            processingScope.setVariable('%s_maxy' % name, layer.extent().yMaximum())
            if isinstance(layer, QgsRasterLayer):
                cellsize = (layer.extent().xMaximum()
                            - layer.extent().xMinimum()) / layer.width()
                processingScope.setVariable('%s_cellsize' % name, cellsize)

        layers = dataobjects.getRasterLayers()
        for layer in layers:
            for i in range(layer.bandCount()):
                stats = layer.dataProvider().bandStatistics(i + 1)
                processingScope.setVariable('%s_band%i_avg' % (name, i + 1), stats.mean)
                processingScope.setVariable('%s_band%i_stddev' % (name, i + 1), stats.stdDev)
                processingScope.setVariable('%s_band%i_min' % (name, i + 1), stats.minimumValue)
                processingScope.setVariable('%s_band%i_max' % (name, i + 1), stats.maximumValue)

        extent = iface.mapCanvas().extent()
        processingScope.setVariable('canvasextent_minx', extent.xMinimum())
        processingScope.setVariable('canvasextent_miny', extent.yMinimum())
        processingScope.setVariable('canvasextent_maxx', extent.xMaximum())
        processingScope.setVariable('canvasextent_maxy', extent.yMaximum())

        extent = iface.mapCanvas().fullExtent()
        processingScope.setVariable('fullextent_minx', extent.xMinimum())
        processingScope.setVariable('fullextent_miny', extent.yMinimum())
        processingScope.setVariable('fullextent_maxx', extent.xMaximum())
        processingScope.setVariable('fullextent_maxy', extent.yMaximum())
        context.appendScope(processingScope)
        return context
Exemple #20
0
    def fillTree(self):
        layersItem = QTreeWidgetItem()
        layersItem.setText(0, self.tr('Values from data layers extents'))
        self.treeValues.addTopLevelItem(layersItem)
        layers = dataobjects.getAllLayers()
        for layer in layers:
            layerItem = QTreeWidgetItem()
            layerItem.setText(0, unicode(layer.name()))
            layerItem.addChild(
                TreeValueItem(self.tr('Min X'),
                              layer.extent().xMinimum()))
            layerItem.addChild(
                TreeValueItem(self.tr('Max X'),
                              layer.extent().xMaximum()))
            layerItem.addChild(
                TreeValueItem(self.tr('Min Y'),
                              layer.extent().yMinimum()))
            layerItem.addChild(
                TreeValueItem(self.tr('Max Y'),
                              layer.extent().yMaximum()))
            if isinstance(layer, QgsRasterLayer):
                cellsize = (layer.extent().xMaximum() -
                            layer.extent().xMinimum()) / layer.width()
                layerItem.addChild(TreeValueItem(self.tr('Cellsize'),
                                                 cellsize))
            layersItem.addChild(layerItem)

        layersItem = QTreeWidgetItem()
        layersItem.setText(0, self.tr('Values from raster layers statistics'))
        self.treeValues.addTopLevelItem(layersItem)
        layers = dataobjects.getRasterLayers()
        for layer in layers:
            for i in range(layer.bandCount()):
                stats = layer.dataProvider().bandStatistics(i + 1)
                layerItem = QTreeWidgetItem()
                layerItem.setText(0, unicode(layer.name()))
                layerItem.addChild(TreeValueItem(self.tr('Mean'), stats.mean))
                layerItem.addChild(
                    TreeValueItem(self.tr('Std. deviation'), stats.stdDev))
                layerItem.addChild(
                    TreeValueItem(self.tr('Max value'), stats.maximumValue))
                layerItem.addChild(
                    TreeValueItem(self.tr('Min value'), stats.minimumValue))
                layersItem.addChild(layerItem)

        canvasItem = QTreeWidgetItem()
        canvasItem.setText(0, self.tr('Values from QGIS map canvas'))
        self.treeValues.addTopLevelItem(canvasItem)
        extent = interface.iface.mapCanvas().extent()
        extentItem = QTreeWidgetItem()
        extentItem.setText(0, self.tr('Current extent'))
        extentItem.addChild(TreeValueItem(self.tr('Min X'), extent.xMinimum()))
        extentItem.addChild(TreeValueItem(self.tr('Max X'), extent.xMaximum()))
        extentItem.addChild(TreeValueItem(self.tr('Min Y'), extent.yMinimum()))
        extentItem.addChild(TreeValueItem(self.tr('Max Y'), extent.yMaximum()))
        canvasItem.addChild(extentItem)

        extent = interface.iface.mapCanvas().fullExtent()
        extentItem = QTreeWidgetItem()
        extentItem.setText(0,
                           self.tr('Full extent of all layers in map canvas'))
        extentItem.addChild(TreeValueItem(self.tr('Min X'), extent.xMinimum()))
        extentItem.addChild(TreeValueItem(self.tr('Max X'), extent.xMaximum()))
        extentItem.addChild(TreeValueItem(self.tr('Min Y'), extent.yMinimum()))
        extentItem.addChild(TreeValueItem(self.tr('Max Y'), extent.yMaximum()))
        canvasItem.addChild(extentItem)
    def fillTree(self):
        layersItem = QTreeWidgetItem()
        layersItem.setText(0, self.tr('Values from data layers extents'))
        self.treeValues.addTopLevelItem(layersItem)
        layers = dataobjects.getAllLayers()
        for layer in layers:
            layerItem = QTreeWidgetItem()
            layerItem.setText(0, unicode(layer.name()))
            layerItem.addChild(TreeValueItem(self.tr('Min X'),
                               layer.extent().xMinimum()))
            layerItem.addChild(TreeValueItem(self.tr('Max X'),
                               layer.extent().xMaximum()))
            layerItem.addChild(TreeValueItem(self.tr('Min Y'),
                               layer.extent().yMinimum()))
            layerItem.addChild(TreeValueItem(self.tr('Max Y'),
                               layer.extent().yMaximum()))
            if isinstance(layer, QgsRasterLayer):
                cellsize = (layer.extent().xMaximum()
                            - layer.extent().xMinimum()) / layer.width()
                layerItem.addChild(TreeValueItem(self.tr('Cellsize'),
                                                 cellsize))
            layersItem.addChild(layerItem)

        layersItem = QTreeWidgetItem()
        layersItem.setText(0, self.tr('Values from raster layers statistics'))
        self.treeValues.addTopLevelItem(layersItem)
        layers = dataobjects.getRasterLayers()
        for layer in layers:
            for i in range(layer.bandCount()):
                stats = layer.dataProvider().bandStatistics(i + 1)
                layerItem = QTreeWidgetItem()
                layerItem.setText(0, unicode(layer.name()))
                layerItem.addChild(TreeValueItem(self.tr('Mean'), stats.mean))
                layerItem.addChild(TreeValueItem(self.tr('Std. deviation'),
                                   stats.stdDev))
                layerItem.addChild(TreeValueItem(self.tr('Max value'),
                                   stats.maximumValue))
                layerItem.addChild(TreeValueItem(self.tr('Min value'),
                                   stats.minimumValue))
                layersItem.addChild(layerItem)

        canvasItem = QTreeWidgetItem()
        canvasItem.setText(0, self.tr('Values from QGIS map canvas'))
        self.treeValues.addTopLevelItem(canvasItem)
        extent = iface.mapCanvas().extent()
        extentItem = QTreeWidgetItem()
        extentItem.setText(0, self.tr('Current extent'))
        extentItem.addChild(TreeValueItem(self.tr('Min X'), extent.xMinimum()))
        extentItem.addChild(TreeValueItem(self.tr('Max X'), extent.xMaximum()))
        extentItem.addChild(TreeValueItem(self.tr('Min Y'), extent.yMinimum()))
        extentItem.addChild(TreeValueItem(self.tr('Max Y'), extent.yMaximum()))
        canvasItem.addChild(extentItem)

        extent = iface.mapCanvas().fullExtent()
        extentItem = QTreeWidgetItem()
        extentItem.setText(0,
                self.tr('Full extent of all layers in map canvas'))
        extentItem.addChild(TreeValueItem(self.tr('Min X'), extent.xMinimum()))
        extentItem.addChild(TreeValueItem(self.tr('Max X'), extent.xMaximum()))
        extentItem.addChild(TreeValueItem(self.tr('Min Y'), extent.yMinimum()))
        extentItem.addChild(TreeValueItem(self.tr('Max Y'), extent.yMaximum()))
        canvasItem.addChild(extentItem)