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


Python core.QgsRasterLayer方法代码示例

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


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

示例1: cargar_mapa_raster

# 需要导入模块: from qgis import core [as 别名]
# 或者: from qgis.core import QgsRasterLayer [as 别名]
def cargar_mapa_raster (self,pathMapaRaster):
    
        retornoCargaLayerMapaRaster = False
    
        pathMapaRaster = pathMapaRaster.strip ()
    
        if (os.path.exists (pathMapaRaster)):
    
            baseNameMapaRaster   = os.path.basename (pathMapaRaster)
            baseNameMapaRaster = os.path.splitext(baseNameMapaRaster)[0]
            layerMapaRaster = QgsRasterLayer (pathMapaRaster, baseNameMapaRaster)
            QgsProject.instance ().addMapLayer (layerMapaRaster)
    
            retornoCargaLayerMapaRaster = layerMapaRaster.isValid()
    
        return retornoCargaLayerMapaRaster 
开发者ID:nicolas998,项目名称:WMF,代码行数:18,代码来源:HydroSEDPluginUtils.py

示例2: calcIsoTinInterpolation

# 需要导入模块: from qgis import core [as 别名]
# 或者: from qgis.core import QgsRasterLayer [as 别名]
def calcIsoTinInterpolation(self, iso_point_layer, resolution, interpolation_raster_path):
        if self.AnalysisCrs.isGeographic():
            raise QgsProcessingException('The TIN-Interpolation algorithm in QGIS is designed to work with projected coordinate systems.Please use a projected coordinate system (eg. UTM zones) instead of geographic coordinate systems (eg. WGS84)!')
        
        layer_data = QgsInterpolator.LayerData()
        QgsInterpolator.LayerData
        
        layer_data.source = iso_point_layer #in QGIS2: vectorLayer
        layer_data.valueSource = QgsInterpolator.ValueAttribute
        layer_data.interpolationAttribute =  1 #take second field to get costs
        layer_data.sourceType = QgsInterpolator.SourcePoints

        tin_interpolator = QgsTinInterpolator([layer_data], QgsTinInterpolator.Linear)
        
        rect = iso_point_layer.extent()
        ncol = int((rect.xMaximum() - rect.xMinimum()) / resolution)
        nrows = int((rect.yMaximum() - rect.yMinimum()) / resolution)
        
        writer = QgsGridFileWriter(tin_interpolator, interpolation_raster_path, rect, ncol, nrows)
        writer.writeFile(self.feedback)  # Creating .asc raste
        return QgsRasterLayer(interpolation_raster_path, "temp_qneat3_interpolation_raster") 
开发者ID:root676,项目名称:QNEAT3,代码行数:23,代码来源:Qneat3Framework.py

示例3: __init__

# 需要导入模块: from qgis import core [as 别名]
# 或者: from qgis.core import QgsRasterLayer [as 别名]
def __init__(self, iface, parent):
        """
        Class constructor.
        """
        # super(QgsRasterLayer, self).__init__()
        self.canvas = iface.mapCanvas()
        super(BandValueTool, self).__init__(self.canvas)
        self.parent = parent
        self.iface = iface
        self.toolAction = None
        self.QgsMapToolEmitPoint = QgsMapToolEmitPoint(self.canvas)
        self.geometryHandler = GeometryHandler(iface)
        self.timerMapTips = QTimer( self.canvas )
        self.timerMapTips.timeout.connect( self.showToolTip )
        self.activated = False
        self.canvasCrs = self.canvas.mapRenderer().destinationCrs() 
开发者ID:dsgoficial,项目名称:DsgTools,代码行数:18,代码来源:bandValueTool.py

示例4: finishedTask

# 需要导入模块: from qgis import core [as 别名]
# 或者: from qgis.core import QgsRasterLayer [as 别名]
def finishedTask(self, e, result=None):
        """ Common finish task function """
        if e is None:
            if result is None:
                qgsu.showUserAndLogMessage(QCoreApplication.translate(
                    "QgsFmvPlayer", 'Completed with no exception and no result '
                    '(probably manually canceled by the user)'), level=QGis.Warning)
            else:
                if "Georeferencing" in result['task']:
                    return
                qgsu.showUserAndLogMessage(QCoreApplication.translate(
                    "QgsFmvPlayer", "Succesfully " + result['task'] + "!"))
                if "Bitrate" in result['task']:
                    self.matplot = ShowPlot(self.BitratePlot.bitrate_data, self.BitratePlot.frame_count, self.fileName, self.BitratePlot.output)
                if result['task'] == 'Show Video Info Task':
                    self.showVideoInfoDialog(self.converter.bytes_value)
                if result['task'] == 'Save Current Georeferenced Frame Task':
                    buttonReply = qgsu.CustomMessage(
                        QCoreApplication.translate("QgsFmvPlayer", "Information"),
                        QCoreApplication.translate("QgsFmvPlayer", "Do you want to load the layer?"),
                        icon="Information")
                    if buttonReply == QMessageBox.Yes:
                        file = result['file']
                        root, _ = os.path.splitext(file)
                        layer = QgsRasterLayer(file, root)
                        QgsProject.instance().addMapLayer(layer)
                    return
        else:
            qgsu.showUserAndLogMessage(QCoreApplication.translate(
                "QgsFmvPlayer", "Failed " + result['task'] + "!"), level=QGis.Warning)
            raise e 
开发者ID:All4Gis,项目名称:QGISFMV,代码行数:33,代码来源:QgsFmvPlayer.py

示例5: add_ee_image_layer

# 需要导入模块: from qgis import core [as 别名]
# 或者: from qgis.core import QgsRasterLayer [as 别名]
def add_ee_image_layer(image, name, shown, opacity):
    check_version()

    url = "type=xyz&url=" + get_ee_image_url(image)
    layer = QgsRasterLayer(url, name, "EE")

    QgsProject.instance().addMapLayer(layer)

    if not (shown is None):
        QgsProject.instance().layerTreeRoot().findLayer(
            layer.id()).setItemVisibilityChecked(shown)

    return layer 
开发者ID:gee-community,项目名称:qgis-earthengine-plugin,代码行数:15,代码来源:utils.py

示例6: createVrt

# 需要导入模块: from qgis import core [as 别名]
# 或者: from qgis.core import QgsRasterLayer [as 别名]
def createVrt(vrt):
    """
    Creates a VRT file
    """
    count = 0
    size = len(list(vrt.keys()))
    p = 0
    progress.setPercentage(p)    
    for key in list(vrt.keys()):
        vrtfilename = os.path.join(Pasta, key, key+'.vrt')
        features = vrt[key]
        rasterList = []
        for feat in features:
            filename = feat['fileName']
            newfilename = copyFileSet(Pasta, key, filename)
            raster = QgsRasterLayer(newfilename, newfilename)
            rasterList.append(raster)
            ovr = newfilename+'.ovr'
            if not os.path.isfile(ovr):
                progress.setText('Fazendo Pirâmides...')
                #('gdalogr:overviews', input, levels=8, clean=False, resampling_method=0(nearest), format=1(Gtiff .ovr))
                processing.runalg('gdalogr:overviews', raster, '4 8 32 128', True, 0, 1)
        
        if int(float(count)/size*100) != p:
            p = int(float(count)/size*100)
            progress.setPercentage(p)    
        count += 1
    
        progress.setText('Fazendo raster virtual...')
        processing.runalg('gdalogr:buildvirtualraster', rasterList, 0, False, False, vrtfilename) 
开发者ID:dsgoficial,项目名称:DsgTools,代码行数:32,代码来源:virtual_raster.py

示例7: createVrt

# 需要导入模块: from qgis import core [as 别名]
# 或者: from qgis.core import QgsRasterLayer [as 别名]
def createVrt(inventario, vrt):
    #Camada de inventario
    layer = processing.getObject(Inventario)
    
    count = 0
    size = layer.featureCount()
    p = 0
    progress.setPercentage(p)    
    rasterList = []
    for feature in layer.getFeatures():
        filename = feature['fileName']
        
        raster = QgsRasterLayer(filename, filename)
        if Override_CRS:
            raster.setCrs( QgsCoordinateReferenceSystem(int(CRS.split(':')[-1]), QgsCoordinateReferenceSystem.EpsgCrsId) )
           
        rasterList.append(raster)
        ovr = filename+'.ovr'
        if not os.path.isfile(ovr):
            progress.setText('Fazendo Pirâmides...')
            #('gdalogr:overviews', input, levels=8, clean=False, resampling_method=0(nearest), format=1(Gtiff .ovr))
            processing.runalg('gdalogr:overviews', raster, '4 8 32 128', True, 0, 1)

        if int(float(count)/size*100) != p:
            p = int(float(count)/size*100)
            progress.setPercentage(p)    
        count += 1
    progress.setText('Fazendo raster virtual...')
    processing.runalg('gdalogr:buildvirtualraster', rasterList, 0, False, False, VRT)
#end of script methods
        
#Making the actual work 
开发者ID:dsgoficial,项目名称:DsgTools,代码行数:34,代码来源:virtual_raster_inloco.py


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