本文整理汇总了Python中processing.core.QGisLayers.QGisLayers.getAllLayers方法的典型用法代码示例。如果您正苦于以下问题:Python QGisLayers.getAllLayers方法的具体用法?Python QGisLayers.getAllLayers怎么用?Python QGisLayers.getAllLayers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类processing.core.QGisLayers.QGisLayers
的用法示例。
在下文中一共展示了QGisLayers.getAllLayers方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fillTree
# 需要导入模块: from processing.core.QGisLayers import QGisLayers [as 别名]
# 或者: from processing.core.QGisLayers.QGisLayers import getAllLayers [as 别名]
def fillTree(self):
layersItem = QtGui.QTreeWidgetItem()
layersItem.setText(0, "Values from data layers extents")
self.tree.addTopLevelItem(layersItem)
layers = QGisLayers.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 = QGisLayers.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 = QGisLayers.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 = QGisLayers.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)
示例2: useLayerExtent
# 需要导入模块: from processing.core.QGisLayers import QGisLayers [as 别名]
# 或者: from processing.core.QGisLayers.QGisLayers import getAllLayers [as 别名]
def useLayerExtent(self):
CANVAS_KEY = "Use canvas extent"
extentsDict = {}
extentsDict[CANVAS_KEY] = QGisLayers.iface.mapCanvas().extent()
extents = [CANVAS_KEY]
layers = QGisLayers.getAllLayers()
for layer in layers:
extents.append(layer.name())
extentsDict[layer.name()] = layer.extent()
item, ok = QtGui.QInputDialog.getItem(self, "Select extent", "Use extent from", extents, False)
if ok:
self.setValueFromRect(extentsDict[item])
示例3: checkInputCRS
# 需要导入模块: from processing.core.QGisLayers import QGisLayers [as 别名]
# 或者: from processing.core.QGisLayers.QGisLayers import getAllLayers [as 别名]
def checkInputCRS(self):
'''it checks that all input layers use the same CRS. If so, returns True. False otherwise'''
crs = None;
layers = QGisLayers.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
示例4: setOutputCRS
# 需要导入模块: from processing.core.QGisLayers import QGisLayers [as 别名]
# 或者: from processing.core.QGisLayers.QGisLayers import getAllLayers [as 别名]
def setOutputCRS(self):
layers = QGisLayers.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 = QGisLayers.iface
self.crs = qgis.mapCanvas().mapRenderer().destinationCrs()
示例5: getfromname
# 需要导入模块: from processing.core.QGisLayers import QGisLayers [as 别名]
# 或者: from processing.core.QGisLayers.QGisLayers import getAllLayers [as 别名]
def getfromname(name):
layers = QGisLayers.getAllLayers()
for layer in layers:
if layer.name() == name:
return layer