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


Python ProcessingUtils.ProcessingUtils类代码示例

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


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

示例1: checkRIsInstalled

    def checkRIsInstalled(ignoreRegistrySettings=False):
        if ProcessingUtils.isWindows():
            path = RUtils.RFolder()
            if path == "":
                return "R folder is not configured.\nPlease configure it before running R scripts."

        R_INSTALLED = "R_INSTALLED"
        settings = QSettings()
        if not ignoreRegistrySettings:
            if settings.contains(R_INSTALLED):
                return
        if ProcessingUtils.isWindows():
            if ProcessingConfig.getSetting(RUtils.R_USE64):
                execDir = "x64"
            else:
                execDir = "i386"
            command = [RUtils.RFolder() + os.sep + "bin" + os.sep + execDir + os.sep + "R.exe", "--version"]
        else:
            command = ["R --version"]
        proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE,stderr=subprocess.STDOUT, universal_newlines=True).stdout

        for line in iter(proc.readline, ""):
            if "R version" in line:
                settings.setValue(R_INSTALLED, True)
                return
        html = ("<p>This algorithm requires R to be run."
            "Unfortunately, it seems that R is not installed in your system, or it is not correctly configured to be used from QGIS</p>"
            '<p><a href= "http://docs.qgis.org/2.0/html/en/docs/user_manual/processing/3rdParty.html">Click here</a>'
             'to know more about how to install and configure R to be used with QGIS</p>')
        return html
开发者ID:alextheleritis,项目名称:QGIS,代码行数:30,代码来源:RUtils.py

示例2: processAlgorithm

    def processAlgorithm(self, progress):
        #TODO:check correct num of bands
        input = self.getParameterValue(SplitRGBBands.INPUT)
        temp = ProcessingUtils.getTempFilename(None).replace('.','');
        basename = os.path.basename(temp)
        validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
        safeBasename = ''.join(c for c in basename if c in validChars)
        temp = os.path.join(os.path.dirname(temp), safeBasename)

        r = self.getOutputValue(SplitRGBBands.R)
        g = self.getOutputValue(SplitRGBBands.G)
        b = self.getOutputValue(SplitRGBBands.B)
        commands = []
        if ProcessingUtils.isWindows():
            commands.append("io_gdal 0 -GRIDS \"" + temp + "\" -FILES \"" + input+"\"")
            commands.append("io_gdal 1 -GRIDS \"" + temp + "_0001.sgrd\" -FORMAT 1 -TYPE 0 -FILE \"" + r + "\"");
            commands.append("io_gdal 1 -GRIDS \"" + temp + "_0002.sgrd\" -FORMAT 1 -TYPE 0 -FILE \"" + g + "\"");
            commands.append("io_gdal 1 -GRIDS \"" + temp + "_0003.sgrd\" -FORMAT 1 -TYPE 0 -FILE \"" + b + "\"");
        else:
            commands.append("libio_gdal 0 -GRIDS \"" + temp + "\" -FILES \"" + input + "\"")
            commands.append("libio_gdal 1 -GRIDS \"" + temp + "_0001.sgrd\" -FORMAT 1 -TYPE 0 -FILE \"" + r + "\"");
            commands.append("libio_gdal 1 -GRIDS \"" + temp + "_0002.sgrd\" -FORMAT 1 -TYPE 0 -FILE \"" + g + "\"");
            commands.append("libio_gdal 1 -GRIDS \"" + temp + "_0003.sgrd\" -FORMAT 1 -TYPE 0 -FILE \"" + b + "\"");

        SagaUtils.createSagaBatchJobFileFromSagaCommands(commands)
        SagaUtils.executeSaga(progress);
开发者ID:alextheleritis,项目名称:QGIS,代码行数:26,代码来源:SplitRGBBands.py

示例3: initializeSettings

 def initializeSettings(self):
     AlgorithmProvider.initializeSettings(self)
     if ProcessingUtils.isWindows() or ProcessingUtils.isMac():
         ProcessingConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_FOLDER, "GRASS folder", GrassUtils.grassPath()))
         ProcessingConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_WIN_SHELL, "Msys folder", GrassUtils.grassWinShell()))
     ProcessingConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_LOG_COMMANDS, "Log execution commands", False))
     ProcessingConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_LOG_CONSOLE, "Log console output", False))
开发者ID:alextheleritis,项目名称:QGIS,代码行数:7,代码来源:GrassAlgorithmProvider.py

示例4: otbPath

 def otbPath():
     folder = ProcessingConfig.getSetting(OTBUtils.OTB_FOLDER)
     if folder == None:
         folder = ""
         #try to configure the path automatically
         if ProcessingUtils.isMac():
             testfolder = os.path.join(str(QgsApplication.prefixPath()), "bin")
             if os.path.exists(os.path.join(testfolder, "otbcli")):
                 folder = testfolder
             else:
                 testfolder = "/usr/local/bin"
                 if os.path.exists(os.path.join(testfolder, "otbcli")):
                     folder = testfolder
         elif ProcessingUtils.isWindows():
             testfolder = os.path.dirname(str(QgsApplication.prefixPath()))
             testfolder = os.path.dirname(testfolder)
             testfolder = os.path.join(testfolder,  "bin")
             path = os.path.join(testfolder, "otbcli.bat")
             if os.path.exists(path):
                 folder = testfolder
         else:
             testfolder = "/usr/bin"
             if os.path.exists(os.path.join(testfolder, "otbcli")):
                 folder = testfolder
     return folder
开发者ID:alextheleritis,项目名称:QGIS,代码行数:25,代码来源:OTBUtils.py

示例5: unload

 def unload(self):
     AlgorithmProvider.unload(self)
     if ProcessingUtils.isWindows() or ProcessingUtils.isMac():
         ProcessingConfig.removeSetting(GrassUtils.GRASS_FOLDER)
         ProcessingConfig.removeSetting(GrassUtils.GRASS_WIN_SHELL)
     ProcessingConfig.removeSetting(GrassUtils.GRASS_LOG_COMMANDS)
     ProcessingConfig.removeSetting(GrassUtils.GRASS_LOG_CONSOLE)
开发者ID:alextheleritis,项目名称:QGIS,代码行数:7,代码来源:GrassAlgorithmProvider.py

示例6: exportRasterLayer

 def exportRasterLayer(self, layer):
     destFilename = ProcessingUtils.getTempFilenameInTempFolder(os.path.basename(layer)[0:5] + ".sgrd")
     self.exportedLayers[layer]= destFilename
     saga208 = ProcessingConfig.getSetting(SagaUtils.SAGA_208)
     if ProcessingUtils.isWindows() or ProcessingUtils.isMac() or not saga208:
         return "io_gdal 0 -GRIDS \"" + destFilename + "\" -FILES \"" + layer+"\""
     else:
         return "libio_gdal 0 -GRIDS \"" + destFilename + "\" -FILES \"" + layer + "\""
开发者ID:artfwo,项目名称:Quantum-GIS,代码行数:8,代码来源:SagaAlgorithm.py

示例7: sagaBatchJobFilename

    def sagaBatchJobFilename():

        if ProcessingUtils.isWindows():
            filename = "saga_batch_job.bat"
        else:
            filename = "saga_batch_job.sh"

        batchfile = ProcessingUtils.userFolder() + os.sep + filename

        return batchfile
开发者ID:artfwo,项目名称:Quantum-GIS,代码行数:10,代码来源:SagaUtils.py

示例8: modelsFolder

    def modelsFolder():
        folder = ProcessingConfig.getSetting(ModelerUtils.MODELS_FOLDER)
        if folder == None:
            folder = unicode(os.path.join(ProcessingUtils.userFolder(), "models"))
        mkdir(folder)

        return os.path.abspath(folder)
开发者ID:alextheleritis,项目名称:QGIS,代码行数:7,代码来源:ModelerUtils.py

示例9: test_SagaVectorAlgorithWithUnsupportedInputAndOutputFormat

 def test_SagaVectorAlgorithWithUnsupportedInputAndOutputFormat(self):
     '''this tests both the exporting to shp and then the format change in the output layer'''
     layer = processing.getobject(polygonsGeoJson());
     feature = layer.getFeatures().next()
     selected = [feature.id()]
     layer.setSelectedFeatures(selected)
     outputs=processing.runalg("saga:polygoncentroids",polygonsGeoJson(),True, ProcessingUtils.getTempFilename("geojson"))
     layer.setSelectedFeatures([])
     output=outputs['CENTROIDS']
     layer=QGisLayers.getObjectFromUri(output, True)
     fields=layer.pendingFields()
     expectednames=['ID','POLY_NUM_A','POLY_ST_A']
     expectedtypes=['Real','Real','String']
     names=[str(f.name()) for f in fields]
     types=[str(f.typeName()) for f in fields]
     self.assertEqual(expectednames, names)
     self.assertEqual(expectedtypes, types)
     features=processing.getfeatures(layer)
     self.assertEqual(1, len(features))
     feature=features.next()
     attrs=feature.attributes()
     expectedvalues=["0","1.1","string a"]
     values=[str(attr) for attr in attrs]
     self.assertEqual(expectedvalues, values)
     wkt='POINT(270787.49991451 4458955.46775295)'
     self.assertEqual(wkt, str(feature.geometry().exportToWkt()))
开发者ID:alextheleritis,项目名称:QGIS,代码行数:26,代码来源:SagaTest.py

示例10: executeSaga

 def executeSaga(progress):
     if ProcessingUtils.isWindows():
         command = ["cmd.exe", "/C ", SagaUtils.sagaBatchJobFilename()]
     else:
         os.chmod(SagaUtils.sagaBatchJobFilename(), stat.S_IEXEC | stat.S_IREAD | stat.S_IWRITE)
         command = [SagaUtils.sagaBatchJobFilename()]
     loglines = []
     loglines.append("SAGA execution console output")
     proc = subprocess.Popen(
         command,
         shell=True,
         stdout=subprocess.PIPE,
         stdin=subprocess.PIPE,
         stderr=subprocess.STDOUT,
         universal_newlines=True,
     ).stdout
     for line in iter(proc.readline, ""):
         if "%" in line:
             s = "".join([x for x in line if x.isdigit()])
             try:
                 progress.setPercentage(int(s))
             except:
                 pass
         else:
             line = line.strip()
             if line != "/" and line != "-" and line != "\\" and line != "|":
                 loglines.append(line)
                 progress.setConsoleInfo(line)
     if ProcessingConfig.getSetting(SagaUtils.SAGA_LOG_CONSOLE):
         ProcessingLog.addToLog(ProcessingLog.LOG_INFO, loglines)
开发者ID:artfwo,项目名称:Quantum-GIS,代码行数:30,代码来源:SagaUtils.py

示例11: checkSagaIsInstalled

    def checkSagaIsInstalled(ignoreRegistrySettings=False):
        if ProcessingUtils.isWindows():
            path = SagaUtils.sagaPath()
            if path == "":
                return "SAGA folder is not configured.\nPlease configure it before running SAGA algorithms."
            cmdpath = os.path.join(path, "saga_cmd.exe")
            if not os.path.exists(cmdpath):
                return (
                    "The specified SAGA folder does not contain a valid SAGA executable.\n"
                    + "Please, go to the processing settings dialog, and check that the SAGA\n"
                    + "folder is correctly configured"
                )

        settings = QSettings()
        SAGA_INSTALLED = "/ProcessingQGIS/SagaInstalled"
        if not ignoreRegistrySettings:
            if settings.contains(SAGA_INSTALLED):
                return

        try:
            from processing import runalg

            result = runalg("saga:thiessenpolygons", points(), None)
            if not os.path.exists(result["POLYGONS"]):
                return "It seems that SAGA is not correctly installed in your system.\nPlease install it before running SAGA algorithms."
        except:
            s = traceback.format_exc()
            return "Error while checking SAGA installation. SAGA might not be correctly configured.\n" + s

        settings.setValue(SAGA_INSTALLED, True)
开发者ID:artfwo,项目名称:Quantum-GIS,代码行数:30,代码来源:SagaUtils.py

示例12: checkGrassIsInstalled

    def checkGrassIsInstalled(ignoreRegistrySettings=False):
        if ProcessingUtils.isWindows():
            path = GrassUtils.grassPath()
            if path == "":
                return "GRASS folder is not configured.\nPlease configure it before running SAGA algorithms."
            cmdpath = os.path.join(path, "bin","r.out.gdal.exe")
            if not os.path.exists(cmdpath):
                return ("The specified GRASS folder does not contain a valid set of GRASS modules.\n"
                        + "Please, go to the processing settings dialog, and check that the GRASS\n"
                        + "folder is correctly configured")

        settings = QSettings()
        GRASS_INSTALLED = "/ProcessingQGIS/GrassInstalled"
        if not ignoreRegistrySettings:
            if settings.contains(GRASS_INSTALLED):
                return
        try:
            from processing import runalg
            result = runalg("grass:v.voronoi", points(),False,False,"270778.60198,270855.745301,4458921.97814,4458983.8488",-1,0.0001, 0, None)
            if not os.path.exists(result['output']):
                return "It seems that GRASS is not correctly installed and configured in your system.\nPlease install it before running GRASS algorithms."
        except:
            s = traceback.format_exc()
            return "Error while checking GRASS installation. GRASS might not be correctly configured.\n" + s;

        settings.setValue(GRASS_INSTALLED, True)
开发者ID:alextheleritis,项目名称:QGIS,代码行数:26,代码来源:GrassUtils.py

示例13: exportTable

 def exportTable( table):
     '''Takes a QgsVectorLayer and returns the filename to refer to its attributes table,
     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 isa remote one or db-based (non-file based) one
     Currently, the output is restricted to dbf.
     It also export to a new file if the original one contains non-ascii characters'''
     settings = QSettings()
     systemEncoding = settings.value( "/UI/encoding", "System" )
     output = ProcessingUtils.getTempFilename("dbf")
     provider = table.dataProvider()
     isASCII=True
     try:
         unicode(table.source()).decode("ascii")
     except UnicodeEncodeError:
         isASCII=False
     isDbf = unicode(table.source()).endswith("dbf") or unicode(table.source()).endswith("shp")
     if (not isDbf or not isASCII):
         writer = QgsVectorFileWriter( output, systemEncoding, provider.fields(), QGis.WKBNoGeometry, layer.crs() )
         for feat in table.getFeatures():
             writer.addFeature(feat)
         del writer
         return output
     else:
         filename = unicode(table.source())
         if unicode(table.source()).endswith("shp"):
             return filename[:-3] + "dbf"
         else:
             return filename
开发者ID:alextheleritis,项目名称:QGIS,代码行数:29,代码来源:LayerExporter.py

示例14: test_SagaRasterAlgorithmWithUnsupportedOutputFormat

 def test_SagaRasterAlgorithmWithUnsupportedOutputFormat(self):
     outputs=processing.runalg("saga:convergenceindex",raster(),0,0,ProcessingUtils.getTempFilename("img"))
     output=outputs['RESULT']
     self.assertTrue(os.path.isfile(output))
     dataset=gdal.Open(output, GA_ReadOnly)
     strhash=hash(str(dataset.ReadAsArray(0).tolist()))
     self.assertEqual(strhash, 485390137)
开发者ID:alextheleritis,项目名称:QGIS,代码行数:7,代码来源:SagaTest.py

示例15: test_gdalogrsieveWithUnsupportedOutputFormat

 def test_gdalogrsieveWithUnsupportedOutputFormat(self):
     outputs=processing.runalg("gdalogr:sieve",raster(),2,0, ProcessingUtils.getTempFilename("img"))
     output=outputs['dst_filename']
     self.assertTrue(os.path.isfile(output))
     dataset=gdal.Open(output, GA_ReadOnly)
     strhash=hash(str(dataset.ReadAsArray(0).tolist()))
     self.assertEqual(strhash,-1353696889)
开发者ID:alextheleritis,项目名称:QGIS,代码行数:7,代码来源:GdalTest.py


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