本文整理汇总了Python中qgis._core.QgsMapLayerRegistry类的典型用法代码示例。如果您正苦于以下问题:Python QgsMapLayerRegistry类的具体用法?Python QgsMapLayerRegistry怎么用?Python QgsMapLayerRegistry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QgsMapLayerRegistry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: disconnect_projectsignals
def disconnect_projectsignals(self):
safe_disconnect(QgsMapLayerRegistry.instance().layerWasAdded, self.connect_layer_signals)
safe_disconnect(QgsMapLayerRegistry.instance().layersRemoved, self.layers_removed)
safe_disconnect(self.canvas.layersChanged, self.layers_changed)
safe_disconnect(self.iface.projectRead, self.connect_signals)
safe_disconnect(self.canvas.selectionChanged, self.selection_changed)
safe_disconnect(self.canvas.selectionChanged, self.viewer.selection_changed)
示例2: viewerReady
def viewerReady(self):
"""
Called once the viewer is loaded and ready to get location events.
"""
self.disconnect_signals()
self.connect_signals()
self.iface.projectRead.connect(self.connect_signals)
self.canvas.layersChanged.connect(self.layers_changed)
self.canvas.selectionChanged.connect(self.selection_changed)
self.canvas.selectionChanged.connect(self.viewer.selection_changed)
QgsMapLayerRegistry.instance().layersRemoved.connect(self.layers_removed)
QgsMapLayerRegistry.instance().layerWasAdded.connect(self.connect_layer_signals)
self.center_on_canvas()
self.viewer.activelayercombo.setLayer(self.iface.activeLayer())
示例3: getAllLayerIds
def getAllLayerIds(filter_func):
# FIXME Make this nicer
res = []
for (id, layer) in QgsMapLayerRegistry.instance().mapLayers().iteritems():
if filter_func(layer):
res.append(id)
return res
示例4: layer_from_name
def layer_from_name(layerName):
# Important: If multiple layers with same name exist, it will return the
# first one it finds
for (id, layer) in QgsMapLayerRegistry.instance().mapLayers().iteritems():
if unicode(layer.name()) == layerName:
return layer
return None
示例5: getLayerFromId
def getLayerFromId(layerId):
try:
layer = QgsMapLayerRegistry.instance().mapLayers()[layerId]
return layer
except:
warn("Could not get layer for id {}".format(layerId))
return None
示例6: get_layer
def get_layer(layer_name):
layermap = QgsMapLayerRegistry.instance().mapLayers()
for name, layer in layermap.iteritems():
if layer.name() == layer_name:
if layer.isValid():
return layer
else:
return None
示例7: getLayerAttributes
def getLayerAttributes(layerId):
try:
layer = QgsMapLayerRegistry.instance().mapLayers()[layerId]
fieldmap = layer.pendingFields()
return fieldmap
except:
# OpenLayers, Raster layers don't work with this
warn("Could not get attributes of layer {}".format(layerId))
return None
示例8: getLayerAttributes
def getLayerAttributes(layerId):
try:
layer=QgsMapLayerRegistry.instance().mapLayers()[layerId]
fieldmap = layer.pendingFields()
#TODO v1.7 figure out what to do for fields with fieldmap.fieldOrigin(idx) = QgsFields.OriginEdit/OriginExpression
return fieldmap
except:
# OpenLayers, Raster layers don't work with this
warn("Could not get attributes of layer {}".format(layerId))
return None
示例9: getAllJoinedLayers
def getAllJoinedLayers(layerIds):
"""get the ids of the layers that are joined on the given layerIds"""
allJoined = set()
allLayers = QgsMapLayerRegistry.instance().mapLayers()
for (id, layer) in allLayers.iteritems():
if isRaster(layer):
continue
if id in layerIds: # let's see what the given layers are joined on
allJoined |= getAllJoinIdsOfLayer(layer)
else: # let's see if the other layers join with the given layers
joinsOfCurrentLayer = getAllJoinIdsOfLayer(layer)
if len(joinsOfCurrentLayer & layerIds) > 0:
allJoined.add(id)
return allJoined
示例10: populate
def populate(self, layerIds):
self.tempLayerIndexToId = {}
i = 0
for (id,layer) in QgsMapLayerRegistry.instance().mapLayers().iteritems():
if id in layerIds:
unicode_name = unicode(layer.name())
self.add_layer_to_select(unicode_name)
self.tempLayerIndexToId[i] = id
i+=1
if self.layer_count()== 0:
msg = 'There are no unmanaged layers of requested type in the project!'
QMessageBox.information(self.dialog,'Error', msg)
raise Exception(msg)
# add the attributes of the first layer in the select for gui initialization
self.add_layer_attributes(0)
self.add_connections()
示例11: remove_layer_from_qgis
def remove_layer_from_qgis(id):
QgsMapLayerRegistry.instance().removeMapLayer(id)
sleep(0.1)
示例12: load_layer_to_qgis
def load_layer_to_qgis(layer):
QgsMapLayerRegistry.instance().addMapLayer(layer)
sleep(0.2)
示例13: get_all_layer_names
def get_all_layer_names():
return QgsMapLayerRegistry.instance().mapLayers().keys()
示例14: layer_count
def layer_count():
return len(QgsMapLayerRegistry.instance().mapLayers())
示例15: getNameFromLayerId
def getNameFromLayerId(layerId):
layer = QgsMapLayerRegistry.instance().mapLayers()[layerId]
return unicode(layer.name())