本文整理汇总了Python中processing.core.QGisLayers.QGisLayers.getRasterLayers方法的典型用法代码示例。如果您正苦于以下问题:Python QGisLayers.getRasterLayers方法的具体用法?Python QGisLayers.getRasterLayers怎么用?Python QGisLayers.getRasterLayers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类processing.core.QGisLayers.QGisLayers
的用法示例。
在下文中一共展示了QGisLayers.getRasterLayers方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fillTree
# 需要导入模块: from processing.core.QGisLayers import QGisLayers [as 别名]
# 或者: from processing.core.QGisLayers.QGisLayers import getRasterLayers [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: setValue
# 需要导入模块: from processing.core.QGisLayers import QGisLayers [as 别名]
# 或者: from processing.core.QGisLayers.QGisLayers import getRasterLayers [as 别名]
def setValue(self, obj):
self.exported = None
if obj == None:
if self.optional:
self.value = None
return True
else:
return False
if isinstance(obj, QgsRasterLayer):
self.value = unicode(obj.dataProvider().dataSourceUri())
return True
else:
self.value = unicode(obj)
layers = QGisLayers.getRasterLayers()
for layer in layers:
if layer.name() == self.value:
self.value = unicode(layer.dataProvider().dataSourceUri())
return True
return os.path.exists(self.value)
示例3: getAsString
# 需要导入模块: from processing.core.QGisLayers import QGisLayers [as 别名]
# 或者: from processing.core.QGisLayers.QGisLayers import getRasterLayers [as 别名]
def getAsString(self,value):
if self.datatype == ParameterMultipleInput.TYPE_RASTER:
if isinstance(value, QgsRasterLayer):
return unicode(value.dataProvider().dataSourceUri())
else:
s = unicode(value)
layers = QGisLayers.getRasterLayers()
for layer in layers:
if layer.name() == s:
return unicode(layer.dataProvider().dataSourceUri())
return s
else:
if isinstance(value, QgsVectorLayer):
return unicode(value.source())
else:
s = unicode(value)
layers = QGisLayers.getVectorLayers(self.datatype)
for layer in layers:
if layer.name() == s:
return unicode(layer.source())
return s
示例4: getWidgetFromParameter
# 需要导入模块: from processing.core.QGisLayers import QGisLayers [as 别名]
# 或者: from processing.core.QGisLayers.QGisLayers import getRasterLayers [as 别名]
def getWidgetFromParameter(self, param):
if isinstance(param, ParameterRaster):
layers = QGisLayers.getRasterLayers()
items = []
if (param.optional):
items.append((self.NOT_SELECTED, None))
for layer in layers:
items.append((self.getExtendedLayerName(layer), layer))
item = InputLayerSelectorPanel(items)
elif isinstance(param, ParameterVector):
if self.somethingDependsOnThisParameter(param) or self.alg.allowOnlyOpenedLayers:
item = QtGui.QComboBox()
layers = QGisLayers.getVectorLayers(param.shapetype)
if (param.optional):
item.addItem(self.NOT_SELECTED, None)
for layer in layers:
item.addItem(self.getExtendedLayerName(layer), layer)
item.currentIndexChanged.connect(self.updateDependentFields)
item.name = param.name
else:
layers = QGisLayers.getVectorLayers(param.shapetype)
items = []
if (param.optional):
items.append((self.NOT_SELECTED, None))
for layer in layers:
items.append((self.getExtendedLayerName(layer), layer))
item = InputLayerSelectorPanel(items)
elif isinstance(param, ParameterTable):
if self.somethingDependsOnThisParameter(param):
item = QtGui.QComboBox()
layers = QGisLayers.getTables()
if (param.optional):
item.addItem(self.NOT_SELECTED, None)
for layer in layers:
item.addItem(layer.name(), layer)
item.currentIndexChanged.connect(self.updateDependentFields)
item.name = param.name
else:
layers = QGisLayers.getTables()
items = []
if (param.optional):
items.append((self.NOT_SELECTED, None))
for layer in layers:
items.append((layer.name(), layer))
item = InputLayerSelectorPanel(items)
elif isinstance(param, ParameterBoolean):
item = QtGui.QComboBox()
item.addItem("Yes")
item.addItem("No")
if param.default:
item.setCurrentIndex(0)
else:
item.setCurrentIndex(1)
elif isinstance(param, ParameterTableField):
item = QtGui.QComboBox()
if param.parent in self.dependentItems:
items = self.dependentItems[param.parent]
else:
items = []
self.dependentItems[param.parent] = items
items.append(param.name)
parent = self.alg.getParameterFromName(param.parent)
if isinstance(parent, ParameterVector):
layers = QGisLayers.getVectorLayers(parent.shapetype)
else:
layers = QGisLayers.getTables()
if len(layers)>0:
item.addItems(self.getFields(layers[0], param.datatype))
elif isinstance(param, ParameterSelection):
item = QtGui.QComboBox()
item.addItems(param.options)
item.setCurrentIndex(param.default)
elif isinstance(param, ParameterFixedTable):
item = FixedTablePanel(param)
elif isinstance(param, ParameterRange):
item = RangePanel(param)
elif isinstance(param, ParameterFile):
item = FileSelectionPanel(param.isFolder)
elif isinstance(param, ParameterMultipleInput):
if param.datatype == ParameterMultipleInput.TYPE_RASTER:
options = QGisLayers.getRasterLayers()
elif param.datatype == ParameterMultipleInput.TYPE_VECTOR_ANY:
options = QGisLayers.getVectorLayers()
else:
options = QGisLayers.getVectorLayers(param.datatype)
opts = []
for opt in options:
opts.append(self.getExtendedLayerName(opt))
item = MultipleInputPanel(opts)
elif isinstance(param, ParameterNumber):
item = NumberInputPanel(param.default, param.isInteger)
elif isinstance(param, ParameterExtent):
item = ExtentSelectionPanel(self.parent, self.alg, param.default)
elif isinstance(param, ParameterCrs):
item = CrsSelectionPanel(param.default)
elif isinstance(param, ParameterString):
if param.multiline:
verticalLayout = QtGui.QVBoxLayout()
verticalLayout.setSizeConstraint(QtGui.QLayout.SetDefaultConstraint)
textEdit = QtGui.QPlainTextEdit()
#.........这里部分代码省略.........