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


Python SextanteLog.SextanteLog类代码示例

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


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

示例1: processAlgorithm

    def processAlgorithm(self, progress):
        polyLayer = QGisLayers.getObjectFromUri(self.getParameterValue(self.POLYGONS))
        pointLayer = QGisLayers.getObjectFromUri(self.getParameterValue(self.POINTS))
        fieldName = self.getParameterValue(self.FIELD)

        polyProvider = polyLayer.dataProvider()
        pointProvider = pointLayer.dataProvider()
        if polyProvider.crs() != pointProvider.crs():
            SextanteLog.addToLog(SextanteLog.LOG_WARNING,
                                 "CRS warning: Input layers have non-matching CRS. This may cause unexpected results.")

        idxCount, fieldList = utils.findOrCreateField(polyLayer, polyLayer.pendingFields(), fieldName)

        writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fieldList,
                     polyProvider.geometryType(), polyProvider.crs())

        spatialIndex = utils.createSpatialIndex(pointLayer)

        pointProvider.rewind()
        pointProvider.select()

        allAttrs = polyLayer.pendingAllAttributesList()
        polyLayer.select(allAttrs)

        ftPoly = QgsFeature()
        ftPoint = QgsFeature()
        outFeat = QgsFeature()
        geom = QgsGeometry()

        current = 0
        hasIntersections = False

        features = QGisLayers.features(polyLayer)
        total = 100.0 / float(len(features))
        for ftPoly in features:
            geom = ftPoly.geometry()
            atMap = ftPoly.attributeMap()

            count = 0
            hasIntersections = False
            points = spatialIndex.intersects(geom.boundingBox())
            if len(points) > 0:
                hasIntersections = True

            if hasIntersections:
                for i in points:
                    pointLayer.featureAtId(int(i), ftPoint, True, False)
                    tmpGeom = QgsGeometry(ftPoint.geometry())
                    if geom.contains(tmpGeom):
                        count += 1

            outFeat.setGeometry(geom)
            outFeat.setAttributeMap(atMap)
            outFeat.addAttribute(idxCount, QVariant(count))
            writer.addFeature(outFeat)

            current += 1
            progress.setPercentage(int(current * total))

        del writer
开发者ID:pka,项目名称:qgisenterprise-sextante-plugin,代码行数:60,代码来源:PointsInPolygon.py

示例2: executeGrass

    def executeGrass(commands, progress, outputCommands = None):
        loglines = []
        loglines.append("GRASS execution console output")
        grassOutDone = False
        command = GrassUtils.prepareGrassExecution(commands)
        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 "GRASS_INFO_PERCENT" in line:
                try:
                    progress.setPercentage(int(line[len("GRASS_INFO_PERCENT")+ 2:]))
                except:
                    pass
            else:
                if "r.out" in line or "v.out" in line:
                    grassOutDone = True
                loglines.append(line)
                progress.setConsoleInfo(line)
        # Some GRASS scripts, like r.mapcalculator or r.fillnulls, call other GRASS scripts during execution. This may override any commands that are
        # still to be executed by the subprocess, which are usually the output ones. If that is the case runs the output commands again.
        if not grassOutDone and outputCommands:
            command = GrassUtils.prepareGrassExecution(outputCommands)
            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 "GRASS_INFO_PERCENT" in line:
                    try:
                        progress.setPercentage(int(line[len("GRASS_INFO_PERCENT")+ 2:]))
                    except:
                        pass
                else:
                    loglines.append(line)
                    progress.setConsoleInfo(line)

        if SextanteConfig.getSetting(GrassUtils.GRASS_LOG_CONSOLE):
            SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)
        return loglines;
开发者ID:Nald,项目名称:Quantum-GIS,代码行数:35,代码来源:GrassUtils.py

示例3: defineCharacteristicsFromFile

    def defineCharacteristicsFromFile(self):
        lines = open(self.descriptionFile)
        line = lines.readline().strip("\n").strip()
        self.appkey = line
        line = lines.readline().strip("\n").strip()
        self.cliName = line
        line = lines.readline().strip("\n").strip()
        self.name = line
        line = lines.readline().strip("\n").strip()
        self.group = line
        while line != "":
            try:
                line = line.strip("\n").strip()
                if line.startswith("Parameter"):
                    param = ParameterFactory.getFromString(line)

                    # Hack for initializing the elevation parameters from Sextante configuration
                    if param.name == "-elev.dem.path":
                        param.default = OTBUtils.otbSRTMPath()
                    if param.name == "-elev.dem.geoid":
                        param.default = OTBUtils.otbGeoidPath()
                    self.addParameter(param)
                elif line.startswith("Extent"):
                    self.addParameter(ParameterExtent(self.REGION_OF_INTEREST, "Region of interest", "0,1,0,1"))
                    self.hasROI = True
                else:
                    self.addOutput(OutputFactory.getFromString(line))
                line = lines.readline().strip("\n").strip()
            except Exception,e:
                SextanteLog.addToLog(SextanteLog.LOG_ERROR, "Could not open OTB algorithm: " + self.descriptionFile + "\n" + line)
                raise e
开发者ID:mokerjoke,项目名称:Quantum-GIS,代码行数:31,代码来源:OTBAlgorithm.py

示例4: processAlgorithm

    def processAlgorithm(self, progress):
        if not ogrAvailable:
            SextanteLog.addToLog(SextanteLog.LOG_ERROR, "OGR bindings not installed" )
            return

        input = self.getParameterValue(self.INPUT_LAYER)
        sql = self.getParameterValue(self.SQL)
        ogrLayer = self.ogrConnectionString(input)

        output = self.getOutputValue(self.OUTPUT)

        qDebug("Opening data source '%s'" % ogrLayer)
        poDS = ogr.Open( ogrLayer, False )
        if poDS is None:
            SextanteLog.addToLog(SextanteLog.LOG_ERROR, self.failure(ogrLayer))
            return

        result = self.select_values(poDS, sql)

        f = open(output, "w")
        f.write("<table>")
        for row in result:
            f.write("<tr>")
            for col in row:
                f.write("<td>"+col+"</td>")
            f.write("</tr>")
        f.write("</table>")
        f.close()
开发者ID:Adam-Brown,项目名称:Quantum-GIS,代码行数:28,代码来源:ogrsql.py

示例5: processAlgorithm

    def processAlgorithm(self, progress):
        commands = []
        commands.append(os.path.join(TauDEMUtils.mpiexecPath(), "mpiexec"))

        processNum = SextanteConfig.getSetting(TauDEMUtils.MPI_PROCESSES)
        if processNum <= 0:
          raise GeoAlgorithmExecutionException("Wrong number of MPI processes used.\nPlease set correct number before running TauDEM algorithms.")

        commands.append("-n")
        commands.append(str(processNum))
        commands.append(os.path.join(TauDEMUtils.taudemPath(), self.cmdName))
        commands.append("-ang")
        commands.append(self.getParameterValue(self.DINF_FLOW_DIR_GRID))
        commands.append("-fel")
        commands.append(self.getParameterValue(self.PIT_FILLED_GRID))
        commands.append("-m")
        commands.append(str(self.STAT_DICT[self.getParameterValue(self.STAT_METHOD)]))
        commands.append(str(self.DIST_DICT[self.getParameterValue(self.DIST_METHOD)]))
        commands.append("-thresh")
        commands.append(str(self.getParameterValue(self.THRESHOLD)))
        if str(self.getParameterValue(self.EDGE_CONTAM)).lower() == "false":
            commands.append("-nc")
        commands.append("-du")
        commands.append(self.getOutputValue(self.DIST_UP_GRID))

        loglines = []
        loglines.append("TauDEM execution command")
        for line in commands:
            loglines.append(line)
        SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)

        TauDEMUtils.executeTauDEM(commands, progress)
开发者ID:Hardysong,项目名称:Quantum-GIS,代码行数:32,代码来源:dinfdistup.py

示例6: processAlgorithm

    def processAlgorithm(self, progress):
        '''Here is where the processing itself takes place'''

        input = self.getParameterValue(self.INPUT_LAYER)
        ogrLayer = self.ogrConnectionString(input)
        output = self.getOutputValue(self.OUTPUT_LAYER)

        #dst_ds = self.getParameterValue(self.DEST_DS)
        dst_ds = self.ogrConnectionString(output)
        dst_format = self.getParameterValue(self.DEST_FORMAT)
        ogr_dsco = [self.getParameterValue(self.DEST_DSCO)] #TODO: split
        #dst_ds = "PG:dbname='glarus_np' options='-c client_encoding=LATIN9'"
        #dst_format ="PostgreSQL"

        qDebug("Opening data source '%s'" % ogrLayer)
        poDS = ogr.Open( ogrLayer, False )
        if poDS is None:
            SextanteLog.addToLog(SextanteLog.LOG_ERROR, self.failure(ogrLayer))
            return

        srs = osr.SpatialReference()
        srs.ImportFromEPSG( 21781 ) #FIXME
        qDebug("Creating output '%s'" % dst_ds)
        if dst_format == "SQLite" and os.path.isfile(dst_ds):
            os.remove(dst_ds)
        qDebug("Using driver '%s'" % dst_format)
        driver = ogr.GetDriverByName(dst_format)
        poDstDS = driver.CreateDataSource(dst_ds, options = ogr_dsco)
        if poDstDS is None:
            SextanteLog.addToLog(SextanteLog.LOG_ERROR, "Error creating %s" % dst_ds)
            return
        self.ogrtransform(poDS, poDstDS, bOverwrite = True)
开发者ID:hCivil,项目名称:Quantum-GIS,代码行数:32,代码来源:ogr2ogr.py

示例7: error

 def error(self, msg):
     QApplication.restoreOverrideCursor()
     QMessageBox.critical(self, "Error", msg)
     SextanteLog.addToLog(SextanteLog.LOG_ERROR, msg)
     if self.algEx:
         self.algEx.terminate()
     self.table.setEnabled(True)
开发者ID:Hardysong,项目名称:Quantum-GIS,代码行数:7,代码来源:BatchProcessingDialog.py

示例8: processAlgorithm

    def processAlgorithm(self, progress):
        commands = []
        commands.append(os.path.join(TauDEMUtils.mpiexecPath(), "mpiexec"))

        processNum = SextanteConfig.getSetting(TauDEMUtils.MPI_PROCESSES)
        if processNum <= 0:
          raise GeoAlgorithmExecutionException("Wrong number of MPI processes used.\nPlease set correct number before running TauDEM algorithms.")

        commands.append("-n")
        commands.append(str(processNum))
        commands.append(os.path.join(TauDEMUtils.taudemPath(), self.cmdName))
        commands.append("-plen")
        commands.append(self.getParameterValue(self.LENGTH_GRID))
        commands.append("-ad8")
        commands.append(self.getParameterValue(self.CONTRIB_AREA_GRID))
        commands.append("-par")
        commands.append(str(self.getParameterValue(self.THRESHOLD)))
        commands.append(str(self.getParameterValue(self.EXPONENT)))
        commands.append("-ss")
        commands.append(self.getOutputValue(self.STREAM_SOURCE_GRID))

        loglines = []
        loglines.append("TauDEM execution command")
        for line in commands:
            loglines.append(line)
        SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)

        TauDEMUtils.executeTauDEM(commands, progress)
开发者ID:Hardysong,项目名称:Quantum-GIS,代码行数:28,代码来源:lengtharea.py

示例9: executeSaga

 def executeSaga(progress):
     if SextanteUtils.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 SextanteConfig.getSetting(SagaUtils.SAGA_LOG_CONSOLE):
         SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)
开发者ID:Nald,项目名称:Quantum-GIS,代码行数:30,代码来源:SagaUtils.py

示例10: processAlgorithm

    def processAlgorithm(self, progress):
        polyLayer = QGisLayers.getObjectFromUri(self.getParameterValue(self.POLYGONS))
        pointLayer = QGisLayers.getObjectFromUri(self.getParameterValue(self.POINTS))
        fieldName = self.getParameterValue(self.FIELD)
        classFieldName = self.getParameterValue(self.CLASSFIELD)

        polyProvider = polyLayer.dataProvider()
        pointProvider = pointLayer.dataProvider()
        if polyProvider.crs() != pointProvider.crs():
            SextanteLog.addToLog(SextanteLog.LOG_WARNING,
                                 "CRS warning: Input layers have non-matching CRS. This may cause unexpected results.")

        classFieldIndex = pointProvider.fieldNameIndex(classFieldName)
        idxCount, fieldList = utils.findOrCreateField(polyLayer, polyLayer.pendingFields(), fieldName)

        writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fieldList,
                     polyProvider.geometryType(), polyProvider.crs())

        spatialIndex = utils.createSpatialIndex(pointLayer)

        ftPoint = QgsFeature()
        outFeat = QgsFeature()
        geom = QgsGeometry()

        current = 0
        hasIntersections = False

        features = QGisLayers.features(polyLayer)
        total = 100.0 / float(len(features))
        for ftPoly in features:
            geom = ftPoly.geometry()
            atMap = ftPoly.attributes()

            classes = []
            hasIntersections = False
            points = spatialIndex.intersects(geom.boundingBox())
            if len(points) > 0:
                hasIntersections = True

            if hasIntersections:
                for i in points:
                    pointLayer.featureAtId(int(i), ftPoint, True, True)
                    tmpGeom = QgsGeometry(ftPoint.geometry())
                    if geom.contains(tmpGeom):
                        clazz = ftPoint.attributes()[classFieldIndex].toString()
                        if not clazz in classes:
                            classes.append(clazz)

            outFeat.setGeometry(geom)        
            if idxCount == len(atMap):
                atMap.append(QVariant(len(classes)))
            else:
                atMap[idxCount] =  QVariant(len(classes))
            outFeat.setAttributes(atMap)
            writer.addFeature(outFeat)

            current += 1
            progress.setPercentage(current / total)

        del writer
开发者ID:sawajid,项目名称:Quantum-GIS,代码行数:60,代码来源:PointsInPolygonUnique.py

示例11: processAlgorithm

    def processAlgorithm(self, progress):
        layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT))        
        tolerance =self.getParameterValue(self.TOLERANCE)        

        pointsBefore = 0
        pointsAfter = 0

        provider = layer.dataProvider()
        layer.select(layer.pendingAllAttributesList())

        writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(layer.pendingFields(),
                     layer.wkbType(), provider.crs())

        current = 0        
        selection = QGisLayers.features(layer)
        total =  100.0 / float(len(selection))            
        for f in selection:
            featGeometry = QgsGeometry(f.geometry())
            attrMap = f.attributeMap()            
            pointsBefore += self.geomVertexCount(featGeometry)
            newGeometry = featGeometry.simplify(tolerance)
            pointsAfter += self.geomVertexCount(newGeometry)            
            feature = QgsFeature()
            feature.setGeometry(newGeometry)
            feature.setAttributeMap(attrMap)
            writer.addFeature(feature)
            current += 1
            progress.setPercentage(int(current * total))
    
        del writer

        SextanteLog.addToLog(SextanteLog.LOG_INFO, "Simplify: Input geometries have been simplified from"
                             + str(pointsBefore) + " to "  + str(pointsAfter) + " points.")
开发者ID:Nald,项目名称:Quantum-GIS,代码行数:33,代码来源:SimplifyGeometries.py

示例12: processAlgorithm

    def processAlgorithm(self, progress):
        commands.append(os.path.join(TauDEMUtils.mpiexecPath(), "mpiexec"))

        processNum = SextanteConfig.getSetting(TauDEMUtils.MPI_PROCESSES)
        if processNum <= 0:
          raise GeoAlgorithmExecutionException("Wrong number of MPI processes used.\nPlease set correct number before running TauDEM algorithms.")

        commands.append("-n")
        commands.append(str(processNum))
        commands.append(os.path.join(TauDEMUtils.taudemPath(), self.cmdName))
        commands.append("-ad8")
        commands.append(self.getParameterValue(self.D8_CONTRIB_AREA_GRID))
        commands.append("-p")
        commands.append(self.getParameterValue(self.D8_FLOW_DIR_GRID))
        commands.append("-fel")
        commands.append(self.getParameterValue(self.PIT_FILLED_GRID))
        commands.append("-ssa")
        commands.append(self.getParameterValue(self.ACCUM_STREAM_SOURCE_GRID))
        commands.append("-o")
        commands.append(self.getParameterValue(self.OUTLETS_SHAPE))
        commands.append("-par")
        commands.append(str(self.getParameterValue(self.MIN_TRESHOLD)))
        commands.append(str(self.getParameterValue(self.MAX_THRESHOLD)))
        commands.append(str(self.getParameterValue(self.TRESHOLD_NUM)))
        commands.append(str(self.getParameterValue(self.STEPS)))
        commands.append("-drp")
        commands.append(self.getOutputValue(self.DROP_ANALYSIS_FILE))

        loglines = []
        loglines.append("TauDEM execution command")
        for line in commands:
            loglines.append(line)
        SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)

        TauDEMUtils.executeTauDEM(commands, progress)
开发者ID:Adam-Brown,项目名称:Quantum-GIS,代码行数:35,代码来源:dropanalysis.py

示例13: defineCharacteristicsFromFile

 def defineCharacteristicsFromFile(self):
     lines = open(self.descriptionFile)
     line = lines.readline().strip("\n").strip()
     self.grassName = line
     line = lines.readline().strip("\n").strip()
     self.name = line
     line = lines.readline().strip("\n").strip()
     self.group = line
     hasRasterOutput = False
     hasVectorOutput = False
     while line != "":
         try:
             line = line.strip("\n").strip()
             if line.startswith("Parameter"):
                 parameter = ParameterFactory.getFromString(line);
                 self.addParameter(parameter)
                 if isinstance(parameter, ParameterVector):
                    hasVectorOutput = True
                 if isinstance(parameter, ParameterMultipleInput) and parameter.datatype < 3:
                    hasVectorOutput = True                        
             elif line.startswith("*Parameter"):
                 param = ParameterFactory.getFromString(line[1:])
                 param.isAdvanced = True
                 self.addParameter(param)
             else:
                 output = OutputFactory.getFromString(line)
                 self.addOutput(output);
                 if isinstance(output, OutputRaster):
                     hasRasterOutput = True
             line = lines.readline().strip("\n").strip()
         except Exception,e:
             SextanteLog.addToLog(SextanteLog.LOG_ERROR, "Could not open GRASS algorithm: " + self.descriptionFile + "\n" + line)
             raise e
开发者ID:tomyun,项目名称:Quantum-GIS,代码行数:33,代码来源:GrassAlgorithm.py

示例14: runFusion

 def runFusion(commands, progress):
     loglines = []
     loglines.append("Fusion execution console output")
     proc = subprocess.Popen(commands, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE,stderr=subprocess.STDOUT, universal_newlines=False).stdout
     for line in iter(proc.readline, ""):
         loglines.append(line)
     SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)
开发者ID:Adam-Brown,项目名称:Quantum-GIS,代码行数:7,代码来源:FusionUtils.py

示例15: executeGrass

 def executeGrass(commands, progress):
     if SextanteUtils.isWindows():
         GrassUtils.createGrassScript(commands)
         command = ["cmd.exe", "/C ", GrassUtils.grassScriptFilename()]
     else:
         gisrc =  SextanteUtils.userFolder() + os.sep + "sextante.gisrc"
         os.putenv("GISRC", gisrc)
         os.putenv("GRASS_MESSAGE_FORMAT", "gui")
         os.putenv("GRASS_BATCH_JOB", GrassUtils.grassBatchJobFilename())
         GrassUtils.createGrassBatchJobFileFromGrassCommands(commands)
         os.chmod(GrassUtils.grassBatchJobFilename(), stat.S_IEXEC | stat.S_IREAD | stat.S_IWRITE)
         if SextanteUtils.isMac():
             command = GrassUtils.grassPath() + os.sep + "grass.sh " + GrassUtils.grassMapsetFolder() + "/user"
         else:
             command = "grass64 " + GrassUtils.grassMapsetFolder() + "/user"
     loglines = []
     loglines.append("GRASS 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 "GRASS_INFO_PERCENT" in line:
             try:
                 progress.setPercentage(int(line[len("GRASS_INFO_PERCENT")+ 2:]))
             except:
                 pass
         else:
             loglines.append(line)
             progress.setConsoleInfo(line)
     if SextanteConfig.getSetting(GrassUtils.GRASS_LOG_CONSOLE):
         SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)
     shutil.rmtree(GrassUtils.grassMapsetFolder(), True)
开发者ID:mokerjoke,项目名称:Quantum-GIS,代码行数:30,代码来源:GrassUtils.py


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