• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python GdalUtils.GdalUtils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sextante.gdal.GdalUtils.GdalUtils的典型用法代码示例。如果您正苦于以下问题:Python GdalUtils类的具体用法?Python GdalUtils怎么用?Python GdalUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: processAlgorithm

    def processAlgorithm(self, progress):
        
        out = self.getOutputValue(translate.OUTPUT)
        outsize = str(self.getParameterValue(translate.OUTSIZE))
        outsizePerc = str(self.getParameterValue(translate.OUTSIZE_PERC))
        noData = str(self.getParameterValue(translate.NO_DATA))
        expand = str(self.getParameterFromName(translate.EXPAND).options[self.getParameterValue(translate.EXPAND)])
        projwin = str(self.getParameterValue(translate.PROJWIN))
        srs = str(self.getParameterValue(translate.SRS))
        sds = str(self.getParameterValue(translate.SDS))
        extra = str(self.getParameterValue(translate.EXTRA))
        
        commands = ["gdal_translate"]
        commands.append("-of")
        commands.append(GdalUtils.getFormatShortNameFromFilename(out))
        if outsizePerc == "True":
            outsizeStr = "-outsize "+outsize+"% "+outsize+"%"
        else:
            outsizeStr = "-outsize "+outsize+" "+outsize
        commands.append(outsizeStr) 
        commands.append("-a_nodata "+noData)
        if expand != "none":
            commands.append("-expand "+expand)
        regionCoords = projwin.split(",")
        commands.append("-projwin "+regionCoords[0]+" "+regionCoords[3]+" "+regionCoords[1]+" "+regionCoords[2])
        if srs != "":
            commands.append("-a_srs EPSG:"+srs)
        if sds == "True":
            commands.append("-sds")
        commands.append(extra)
        commands.append(self.getParameterValue(translate.INPUT))
        commands.append(out)


        GdalUtils.runGdal(commands, progress)
开发者ID:Nald,项目名称:Quantum-GIS,代码行数:35,代码来源:translate.py


示例2: processAlgorithm

    def processAlgorithm(self, progress):
        arguments = []
        inFile = self.getParameterValue(gdaladdo.INPUT)
        arguments.append(inFile)
        arguments.extend(self.getParameterValue(gdaladdo.LEVELS).split(" "))
        self.setOutputValue(gdaladdo.OUTPUT, inFile)

        GdalUtils.runGdal(["gdaladdo", GdalUtils.escapeAndJoin(arguments)], progress)
开发者ID:Adam-Brown,项目名称:Quantum-GIS,代码行数:8,代码来源:gdaladdo.py


示例3: processAlgorithm

    def processAlgorithm(self, progress):
        commands = ["gdaladdo"]        
        input = self.getParameterValue(gdaladdo.INPUT)
        self.setOutputValue(gdaladdo.OUTPUT, input)                        
        commands.append(input)
        commands.append(self.getParameterValue(gdaladdo.LEVELS))                

        GdalUtils.runGdal(commands, progress)
开发者ID:hCivil,项目名称:Quantum-GIS,代码行数:8,代码来源:gdaladdo.py


示例4: processAlgorithm

    def processAlgorithm(self, progress):
        commands = ["gdal_translate"]
        commands.append("-of")
        out = self.getOutputValue(translate.OUTPUT)
        commands.append(GdalUtils.getFormatShortNameFromFilename(out))
        commands.append(self.getParameterValue(translate.INPUT))
        commands.append(out)

        GdalUtils.runGdal(commands, progress)
开发者ID:mokerjoke,项目名称:Quantum-GIS,代码行数:9,代码来源:translate.py


示例5: processAlgorithm

 def processAlgorithm(self, progress):
     commands = ["nearblack"]
     commands.append("-o")
     commands.append(self.getOutputValue(nearblack.OUTPUT))
     commands.append("-near")
     commands.append(str(self.getParameterValue(nearblack.NEAR)))
     if self.getParameterValue(nearblack.WHITE):
         commands.append("-white")
     commands.append(self.getParameterValue(nearblack.INPUT))
     GdalUtils.runGdal(commands, progress)
开发者ID:carsonfarmer,项目名称:Quantum-GIS,代码行数:10,代码来源:nearblack.py


示例6: processAlgorithm

 def processAlgorithm(self, progress):
     arguments = []
     arguments.append("-o")
     arguments.append(self.getOutputValue(nearblack.OUTPUT))
     arguments.append("-near")
     arguments.append(str(self.getParameterValue(nearblack.NEAR)))
     if self.getParameterValue(nearblack.WHITE):
         arguments.append("-white")
     arguments.append(self.getParameterValue(nearblack.INPUT))
     GdalUtils.runGdal(["nearblack", GdalUtils.escapeAndJoin(arguments)], progress)
开发者ID:Adam-Brown,项目名称:Quantum-GIS,代码行数:10,代码来源:nearblack.py


示例7: processAlgorithm

 def processAlgorithm(self, progress):
     commands = ["gdalinfo"]
     if self.getParameterValue(information.NOGCP):
         commands.append("-nogcp")
     if self.getParameterValue(information.NOMETADATA):
         commands.append("-nomd")
     commands.append(self.getParameterValue(information.INPUT))
     GdalUtils.runGdal(commands, progress)
     output = self.getOutputValue(information.OUTPUT)
     f = open(output, "w")
     for s in GdalUtils.getConsoleOutput()[1:]:
         f.write("<p>" + str(s) + "</p>")
     f.close()
开发者ID:L-Infantini,项目名称:Quantum-GIS,代码行数:13,代码来源:information.py


示例8: processAlgorithm

 def processAlgorithm(self, progress):
     arguments = []
     if self.getParameterValue(information.NOGCP):
         arguments.append("-nogcp")
     if self.getParameterValue(information.NOMETADATA):
         arguments.append("-nomd")
     arguments.append(self.getParameterValue(information.INPUT))
     GdalUtils.runGdal(["gdalinfo", GdalUtils.escapeAndJoin(arguments)], progress)
     output = self.getOutputValue(information.OUTPUT)
     f = open(output, "w")
     for s in GdalUtils.getConsoleOutput()[1:]:
         f.write("<p>" + str(s) + "</p>")
     f.close()
开发者ID:Adam-Brown,项目名称:Quantum-GIS,代码行数:13,代码来源:information.py


示例9: processAlgorithm

    def processAlgorithm(self, progress):
        if SextanteUtils.isWindows():
            commands = ["cmd.exe", "/C ", "pct2rgb.bat"]
        else:
            commands = ["pct2rgb.py"]
        commands.append("-b")
        commands.append(str(self.getParameterValue(pct2rgb.NBAND) + 1))
        commands.append("-of")
        out = self.getOutputValue(pct2rgb.OUTPUT)
        commands.append(GdalUtils.getFormatShortNameFromFilename(out))
        commands.append(self.getParameterValue(pct2rgb.INPUT))
        commands.append(out)

        GdalUtils.runGdal(commands, progress)
开发者ID:mokerjoke,项目名称:Quantum-GIS,代码行数:14,代码来源:pct2rgb.py


示例10: processAlgorithm

 def processAlgorithm(self, progress):
     if SextanteUtils.isWindows():
         commands = ["cmd.exe", "/C ", "gdal_polygonize.bat"]
     else:
         commands = ["gdal_polygonize.py"]
     commands.append(self.getParameterValue(polygonize.INPUT))
     commands.append('-f')
     commands.append('"ESRI Shapefile"')
     output = self.getOutputValue(polygonize.OUTPUT)
     commands.append(output)
     commands.append(QtCore.QFileInfo(output).baseName())
     commands.append(self.getParameterValue(polygonize.FIELD))
     
     GdalUtils.runGdal(commands, progress)
开发者ID:mokerjoke,项目名称:Quantum-GIS,代码行数:14,代码来源:polygonize.py


示例11: getSupportedOutputRasterLayerExtensions

 def getSupportedOutputRasterLayerExtensions():   
     allexts = ["tif"]
     for exts in GdalUtils.getSupportedRasters().values():
         for ext in exts:
             if ext not in allexts:
                 allexts.append(ext)
     return allexts             
开发者ID:sawajid,项目名称:Quantum-GIS,代码行数:7,代码来源:QGisLayers.py


示例12: processAlgorithm

    def processAlgorithm(self, progress):
        if SextanteUtils.isWindows():
            commands = ["cmd.exe", "/C ", "gdal_merge.bat"]
        else:
            commands = ["gdal_merge.py"]
        if self.getParameterValue(merge.SEPARATE):
            commands.append("-separate")
        if self.getParameterValue(merge.PCT):
            commands.append("-pct")
        commands.append("-of")
        out = self.getOutputValue(merge.OUTPUT)
        commands.append(GdalUtils.getFormatShortNameFromFilename(out))
        commands.append(self.getParameterValue(merge.INPUT).replace(";", " "))
        commands.append(out)

        GdalUtils.runGdal(commands, progress)
开发者ID:mokerjoke,项目名称:Quantum-GIS,代码行数:16,代码来源:merge.py


示例13: processAlgorithm

    def processAlgorithm(self, progress):
        arguments = []
        arguments.append("-n")
        arguments.append(str(self.getParameterValue(rgb2pct.NCOLORS)))
        arguments.append("-of")
        out = self.getOutputValue(rgb2pct.OUTPUT)
        arguments.append(GdalUtils.getFormatShortNameFromFilename(out))
        arguments.append(self.getParameterValue(rgb2pct.INPUT))
        arguments.append(out)

        if SextanteUtils.isWindows():
            commands = ["cmd.exe", "/C ", "rgb2pct.bat", GdalUtils.escapeAndJoin(arguments)]
        else:
            commands = ["rgb2pct.py", GdalUtils.escapeAndJoin(arguments)]

        GdalUtils.runGdal(commands, progress)
开发者ID:Adam-Brown,项目名称:Quantum-GIS,代码行数:16,代码来源:rgb2pct.py


示例14: processAlgorithm

    def processAlgorithm(self, progress):
        srs = self.getParameterValue(warp.DEST_SRS)
        self.crs = QgsCoordinateReferenceSystem(int(srs))
        commands = ["gdalwarp"]
        commands.append("-s_srs")
        commands.append("EPSG:" + str(self.getParameterValue(warp.SOURCE_SRS)))
        commands.append("-t_srs")
        commands.append("EPSG:" + str(srs))
        commands.append("-r")
        commands.append(warp.METHOD_OPTIONS[self.getParameterValue(warp.METHOD)])
        commands.append("-of")
        out = self.getOutputValue(warp.OUTPUT)
        commands.append(GdalUtils.getFormatShortNameFromFilename(out))
        commands.append(self.getParameterValue(warp.INPUT))
        commands.append(out)

        GdalUtils.runGdal(commands, progress)
开发者ID:carsonfarmer,项目名称:Quantum-GIS,代码行数:17,代码来源:warp.py


示例15: getFormatShortNameFromFilename

 def getFormatShortNameFromFilename(self, filename):
     ext = filename[filename.rfind(".")+1:]
     supported = GdalUtils.getSupportedRasters()
     for name in supported.keys():
         exts = supported[name]
         if ext in exts:
             return name
     return "GTiff"
开发者ID:Hardysong,项目名称:Quantum-GIS,代码行数:8,代码来源:GeoAlgorithm.py


示例16: processAlgorithm

    def processAlgorithm(self, progress):
        out = self.getOutputValue(translate.OUTPUT)
        outsize = str(self.getParameterValue(translate.OUTSIZE))
        outsizePerc = str(self.getParameterValue(translate.OUTSIZE_PERC))
        noData = str(self.getParameterValue(translate.NO_DATA))
        expand = str(self.getParameterFromName(translate.EXPAND).options[self.getParameterValue(translate.EXPAND)])
        projwin = str(self.getParameterValue(translate.PROJWIN))
        crsId = self.getParameterValue(translate.SRS)
        sds = self.getParameterValue(translate.SDS)
        extra = str(self.getParameterValue(translate.EXTRA))

        arguments = []
        arguments.append("-of")
        arguments.append(GdalUtils.getFormatShortNameFromFilename(out))
        if outsizePerc == "True":
            arguments.append("-outsize")
            arguments.append(outsize + "%")
            arguments.append(outsize + "%")
        else:
            arguments.append("-outsize")
            arguments.append(outsize)
            arguments.append(outsize)
        arguments.append("-a_nodata")
        arguments.append(noData)
        if expand != "none":
            arguments.append("-expand")
            arguments.append(expand)
        regionCoords = projwin.split(",")
        arguments.append("-projwin")
        arguments.append(regionCoords[0])
        arguments.append(regionCoords[3])
        arguments.append(regionCoords[1])
        arguments.append(regionCoords[2])
        if crsId is not None:
            arguments.append("-a_srs")
            arguments.append(str(crsId))
            self.crs = QgsCoordinateReferenceSystem(crsId)
        if sds:
            arguments.append("-sds")
        if len(extra) > 0:
            arguments.append(extra)
        arguments.append(self.getParameterValue(translate.INPUT))
        arguments.append(out)

        GdalUtils.runGdal(["gdal_translate", GdalUtils.escapeAndJoin(arguments)], progress)
开发者ID:Adam-Brown,项目名称:Quantum-GIS,代码行数:45,代码来源:translate.py


示例17: processAlgorithm

    def processAlgorithm(self, progress):
        arguments = []
        if self.getParameterValue(merge.SEPARATE):
            arguments.append("-separate")
        if self.getParameterValue(merge.PCT):
            arguments.append("-pct")
        arguments.append("-o")
        out = self.getOutputValue(merge.OUTPUT)
        arguments.append(out)
        arguments.append("-of")
        arguments.append(GdalUtils.getFormatShortNameFromFilename(out))
        arguments.extend(self.getParameterValue(merge.INPUT).split(";"))

        commands = []
        if SextanteUtils.isWindows():
            commands = ["cmd.exe", "/C ", "gdal_merge.bat", GdalUtils.escapeAndJoin(arguments)]
        else:
            commands = ["gdal_merge.py", GdalUtils.escapeAndJoin(arguments)]

        GdalUtils.runGdal(commands, progress)
开发者ID:jetuk,项目名称:Quantum-GIS,代码行数:20,代码来源:merge.py


示例18: exportRasterLayer

    def exportRasterLayer(layer):
        '''Takes a QgsRasterLayer and returns the filename to refer to it, which allows external
        apps which support only file-based layers to use it. It performs the necessary export
        in case the input layer is not in a standard format suitable for most applications, it is
        a remote one or db-based (non-file based) one
        Currently, the output is restricted to geotiff, but not all other formats are exported.
        Only those formats not supported by GDAL are exported, so it is assumed that the external
        app uses GDAL to read the layer'''
        exts = GdalUtils.getSupportedRasterExtensions()
        for ext in exts:
            if (unicode(layer.source()).endswith(ext)):
                return unicode(layer.source())

        #TODO:Do the conversion here
        return unicode(layer.source())
开发者ID:mokerjoke,项目名称:Quantum-GIS,代码行数:15,代码来源:LayerExporter.py


示例19: processAlgorithm

    def processAlgorithm(self, progress):
        arguments = []
        arguments.append("-s_srs")
        arguments.append(str(self.getParameterValue(warp.SOURCE_SRS)))
        arguments.append("-t_srs")
        crsId = self.getParameterValue(warp.DEST_SRS)
        self.crs = QgsCoordinateReferenceSystem(crsId)
        arguments.append(str(crsId))
        arguments.append("-r")
        arguments.append(warp.METHOD_OPTIONS[self.getParameterValue(warp.METHOD)])
        arguments.append("-of")
        out = self.getOutputValue(warp.OUTPUT)
        arguments.append(GdalUtils.getFormatShortNameFromFilename(out))
        if self.getParameterValue(warp.TR) != 0:
            arguments.append("-tr")
            arguments.append(str(self.getParameterValue(warp.TR)))
            arguments.append(str(self.getParameterValue(warp.TR)))
        extra = str(self.getParameterValue(warp.EXTRA))
        if len(extra) > 0:
            arguments.append(extra)
        arguments.append(self.getParameterValue(warp.INPUT))
        arguments.append(out)

        GdalUtils.runGdal(["gdalwarp", GdalUtils.escapeAndJoin(arguments)], progress)
开发者ID:Adam-Brown,项目名称:Quantum-GIS,代码行数:24,代码来源:warp.py


示例20:

try:
    driver = gdal.IdentifyDriver( dst_filename )
    if driver is not None:
        dst_ds = gdal.Open( dst_filename, gdal.GA_Update )
        dstband = dst_ds.GetRasterBand(dst_band_n)
    else:
        dst_ds = None
except:
    dst_ds = None

# =============================================================================
#     Create output file.
# =============================================================================
if dst_ds is None:
    drv = gdal.GetDriverByName(GdalUtils.getFormatShortNameFromFilename(dst_filename))
    dst_ds = drv.Create( dst_filename,
                         src_ds.RasterXSize, src_ds.RasterYSize, 1,
                         gdal.GetDataTypeByName(creation_type) )

    dst_ds.SetGeoTransform( src_ds.GetGeoTransform() )
    dst_ds.SetProjection( src_ds.GetProjectionRef() )

    dstband = dst_ds.GetRasterBand(1)

# =============================================================================
#    Invoke algorithm.
# =============================================================================

prog_func = gdal.TermProgress
gdal.ComputeProximity( srcband, dstband, options,
开发者ID:L-Infantini,项目名称:Quantum-GIS,代码行数:30,代码来源:proximity.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python GrassUtils.GrassUtils类代码示例发布时间:2022-05-27
下一篇:
Python SextanteUtils.SextanteUtils类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap