当前位置: 首页>>代码示例>>Python>>正文


Python QgsMapLayerRegistry.instance方法代码示例

本文整理汇总了Python中qgis._core.QgsMapLayerRegistry.instance方法的典型用法代码示例。如果您正苦于以下问题:Python QgsMapLayerRegistry.instance方法的具体用法?Python QgsMapLayerRegistry.instance怎么用?Python QgsMapLayerRegistry.instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在qgis._core.QgsMapLayerRegistry的用法示例。


在下文中一共展示了QgsMapLayerRegistry.instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: disconnect_projectsignals

# 需要导入模块: from qgis._core import QgsMapLayerRegistry [as 别名]
# 或者: from qgis._core.QgsMapLayerRegistry import instance [as 别名]
 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)
开发者ID:michaelborck,项目名称:earthmine-qgis,代码行数:9,代码来源:earthmine_qgis.py

示例2: viewerReady

# 需要导入模块: from qgis._core import QgsMapLayerRegistry [as 别名]
# 或者: from qgis._core.QgsMapLayerRegistry import instance [as 别名]
 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())
开发者ID:michaelborck,项目名称:earthmine-qgis,代码行数:16,代码来源:earthmine_qgis.py

示例3: getAllLayerIds

# 需要导入模块: from qgis._core import QgsMapLayerRegistry [as 别名]
# 或者: from qgis._core.QgsMapLayerRegistry import instance [as 别名]
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
开发者ID:NathanW2,项目名称:TimeManager,代码行数:9,代码来源:qgis_utils.py

示例4: layer_from_name

# 需要导入模块: from qgis._core import QgsMapLayerRegistry [as 别名]
# 或者: from qgis._core.QgsMapLayerRegistry import instance [as 别名]
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
开发者ID:opengisch,项目名称:shpsync,代码行数:9,代码来源:shp_excel_sync.py

示例5: getLayerFromId

# 需要导入模块: from qgis._core import QgsMapLayerRegistry [as 别名]
# 或者: from qgis._core.QgsMapLayerRegistry import instance [as 别名]
def getLayerFromId(layerId):
    try:
        layer = QgsMapLayerRegistry.instance().mapLayers()[layerId]
        return layer
    except:
        warn("Could not get layer for id {}".format(layerId))
        return None
开发者ID:rduivenvoorde,项目名称:TimeManager,代码行数:9,代码来源:qgis_utils.py

示例6: get_layer

# 需要导入模块: from qgis._core import QgsMapLayerRegistry [as 别名]
# 或者: from qgis._core.QgsMapLayerRegistry import instance [as 别名]
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
开发者ID:jawensi,项目名称:DEMto3D,代码行数:10,代码来源:DEMto3D_dialog.py

示例7: getLayerAttributes

# 需要导入模块: from qgis._core import QgsMapLayerRegistry [as 别名]
# 或者: from qgis._core.QgsMapLayerRegistry import instance [as 别名]
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
开发者ID:carolinux,项目名称:dotfiles,代码行数:11,代码来源:qgis_utils.py

示例8: getLayerAttributes

# 需要导入模块: from qgis._core import QgsMapLayerRegistry [as 别名]
# 或者: from qgis._core.QgsMapLayerRegistry import instance [as 别名]
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
开发者ID:NathanW2,项目名称:TimeManager,代码行数:12,代码来源:qgis_utils.py

示例9: getAllJoinedLayers

# 需要导入模块: from qgis._core import QgsMapLayerRegistry [as 别名]
# 或者: from qgis._core.QgsMapLayerRegistry import instance [as 别名]
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
开发者ID:rduivenvoorde,项目名称:TimeManager,代码行数:17,代码来源:qgis_utils.py

示例10: populate

# 需要导入模块: from qgis._core import QgsMapLayerRegistry [as 别名]
# 或者: from qgis._core.QgsMapLayerRegistry import instance [as 别名]
    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()
开发者ID:timlinux,项目名称:TimeManager,代码行数:20,代码来源:vectorlayerdialog.py

示例11: remove_layer_from_qgis

# 需要导入模块: from qgis._core import QgsMapLayerRegistry [as 别名]
# 或者: from qgis._core.QgsMapLayerRegistry import instance [as 别名]
def remove_layer_from_qgis(id):
    QgsMapLayerRegistry.instance().removeMapLayer(id)
    sleep(0.1)
开发者ID:timlinux,项目名称:TimeManager,代码行数:5,代码来源:within_qgis_script.py

示例12: load_layer_to_qgis

# 需要导入模块: from qgis._core import QgsMapLayerRegistry [as 别名]
# 或者: from qgis._core.QgsMapLayerRegistry import instance [as 别名]
def load_layer_to_qgis(layer):
    QgsMapLayerRegistry.instance().addMapLayer(layer)
    sleep(0.2)
开发者ID:timlinux,项目名称:TimeManager,代码行数:5,代码来源:within_qgis_script.py

示例13: get_all_layer_names

# 需要导入模块: from qgis._core import QgsMapLayerRegistry [as 别名]
# 或者: from qgis._core.QgsMapLayerRegistry import instance [as 别名]
def get_all_layer_names():
     return QgsMapLayerRegistry.instance().mapLayers().keys()
开发者ID:timlinux,项目名称:TimeManager,代码行数:4,代码来源:within_qgis_script.py

示例14: layer_count

# 需要导入模块: from qgis._core import QgsMapLayerRegistry [as 别名]
# 或者: from qgis._core.QgsMapLayerRegistry import instance [as 别名]
def layer_count():
    return len(QgsMapLayerRegistry.instance().mapLayers())
开发者ID:timlinux,项目名称:TimeManager,代码行数:4,代码来源:within_qgis_script.py

示例15: getNameFromLayerId

# 需要导入模块: from qgis._core import QgsMapLayerRegistry [as 别名]
# 或者: from qgis._core.QgsMapLayerRegistry import instance [as 别名]
def getNameFromLayerId(layerId):
    layer = QgsMapLayerRegistry.instance().mapLayers()[layerId]
    return unicode(layer.name())
开发者ID:rduivenvoorde,项目名称:TimeManager,代码行数:5,代码来源:qgis_utils.py


注:本文中的qgis._core.QgsMapLayerRegistry.instance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。