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


Python GrassUtils.createTempMapset方法代码示例

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


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

示例1: processAlgorithm

# 需要导入模块: from sextante.grass.GrassUtils import GrassUtils [as 别名]
# 或者: from sextante.grass.GrassUtils.GrassUtils import createTempMapset [as 别名]
 def processAlgorithm(self, progress):
     commands = []
     command = "nviz"
     vector = self.getParameterValue(self.VECTOR);
     elevation = self.getParameterValue(self.ELEVATION);
     if vector:
         layers = vector.split(";")
         for layer in layers:
             newfilename = self.exportVectorLayer(layer)
             vector = vector.replace(layer, newfilename)
         command += (" vector=" + vector.replace(";", ","))
     if elevation:
         layers = elevation.split(";")
         for layer in layers:
             newfilename = self.exportRasterLayer(layer)
             elevation = elevation.replace(layer, newfilename)
         command += (" elevation=" + elevation.replace(";", ","))
     if elevation is None and vector is None:
         command += " -q"
     commands.append(command)
     GrassUtils.createTempMapset();
     GrassUtils.executeGrass(commands, progress)
开发者ID:mokerjoke,项目名称:Quantum-GIS,代码行数:24,代码来源:nviz.py

示例2: processAlgorithm

# 需要导入模块: from sextante.grass.GrassUtils import GrassUtils [as 别名]
# 或者: from sextante.grass.GrassUtils.GrassUtils import createTempMapset [as 别名]
    def processAlgorithm(self, progress):
        commands = []
        vector = self.getParameterValue(self.VECTOR);
        elevation = self.getParameterValue(self.ELEVATION);

        region = str(self.getParameterValue(self.GRASS_REGION_EXTENT_PARAMETER))
        regionCoords = region.split(",")
        command = "g.region "
        command += "n=" + str(regionCoords[3])
        command +=" s=" + str(regionCoords[2])
        command +=" e=" + str(regionCoords[1])
        command +=" w=" + str(regionCoords[0])
        cellsize = self.getParameterValue(self.GRASS_REGION_CELLSIZE_PARAMETER)
        if cellsize:
            command +=" res=" + str(cellsize);
        else:
            command +=" res=" + str(self.getDefaultCellsize())
        commands.append(command)

        command = "nviz"
        if vector:
            layers = vector.split(";")
            for layer in layers:
                cmd, newfilename = self.exportVectorLayer(layer)
                commands.append(cmd)
                vector = vector.replace(layer, newfilename)
            command += (" vector=" + vector.replace(";", ","))
        if elevation:
            layers = elevation.split(";")
            for layer in layers:
                cmd, newfilename = self.exportRasterLayer(layer)
                commands.append(cmd)
                elevation = elevation.replace(layer, newfilename)
            command += (" elevation=" + elevation.replace(";", ","))
        if elevation is None and vector is None:
            command += " -q"
        commands.append(command)
        GrassUtils.createTempMapset();
        GrassUtils.executeGrass(commands, progress)
开发者ID:Adam-Brown,项目名称:Quantum-GIS,代码行数:41,代码来源:nviz.py

示例3: processAlgorithm

# 需要导入模块: from sextante.grass.GrassUtils import GrassUtils [as 别名]
# 或者: from sextante.grass.GrassUtils.GrassUtils import createTempMapset [as 别名]
    def processAlgorithm(self, progress):
        if SextanteUtils.isWindows():
            path = GrassUtils.grassPath()
            if path == "":
                raise GeoAlgorithmExecutionException("GRASS folder is not configured.\nPlease configure it before running GRASS algorithms.")

        commands = []
        self.exportedLayers = {}

        #self.calculateRegion()
        region = str(self.getParameterValue(self.GRASS_REGION_EXTENT_PARAMETER))
        regionCoords = region.split(",")
        GrassUtils.createTempMapset();

        command = "g.region"
        command += " n=" + str(regionCoords[3])
        command +=" s=" + str(regionCoords[2])
        command +=" e=" + str(regionCoords[1])
        command +=" w=" + str(regionCoords[0])
        command +=" res=" + str(self.getParameterValue(self.GRASS_REGION_CELLSIZE_PARAMETER));
        commands.append(command)

        #1: Export layer to grass mapset
        for param in self.parameters:
            if isinstance(param, ParameterRaster):
                if param.value == None:
                    continue
                value = param.value
                commands.append(self.exportRasterLayer(value))
            if isinstance(param, ParameterVector):
                if param.value == None:
                    continue
                value = param.value
                commands.append(self.exportVectorLayer(value))
            if isinstance(param, ParameterTable):
                pass
            if isinstance(param, ParameterMultipleInput):
                if param.value == None:
                    continue
                layers = param.value.split(";")
                if layers == None or len(layers) == 0:
                    continue
                if param.datatype == ParameterMultipleInput.TYPE_RASTER:
                    for layer in layers:
                        commands.append(self.exportRasterLayer(layer))
                elif param.datatype == ParameterMultipleInput.TYPE_VECTOR_ANY:
                    for layer in layers:
                        commands.append(self.exportVectorLayer(layer))

        #2: set parameters and outputs
        command = self.grassName
        for param in self.parameters:
            if param.value == None:
                continue
            if param.name == self.GRASS_REGION_CELLSIZE_PARAMETER or param.name == self.GRASS_REGION_EXTENT_PARAMETER:
                continue
            if isinstance(param, (ParameterRaster, ParameterVector)):
                value = param.value
                if value in self.exportedLayers.keys():
                    command+=(" " + param.name + "=" + self.exportedLayers[value])
                else:
                    command+=(" " + param.name + "=" + value)
            elif isinstance(param, ParameterMultipleInput):
                s = param.value
                for layer in self.exportedLayers.keys():
                    s = s.replace(layer, self.exportedLayers[layer])
                s = s.replace(";",",")
                command+=(" " + param.name + "=" + s);
            elif isinstance(param, ParameterBoolean):
                if param.value:
                    command += (" " + param.name)
            elif isinstance(param, ParameterSelection):
                idx = int(param.value)
                command+=(" " + param.name + "=" + str(param.options[idx]));
            else:
                command+=(" " + param.name + "=" + str(param.value));

        for out in self.outputs:
            if isinstance(out, OutputFile):
                command+=(" " + out.name + "=\"" + out.value + "\"");
            else:
                command+=(" " + out.name + "=" + out.name);

        command += " --overwrite"
        commands.append(command)

        #3:Export resulting layers to a format that qgis can read
        for out in self.outputs:
            if isinstance(out, OutputRaster):
                filename = out.value
                #Raster layer output: adjust region to layer before exporting
                commands.append("g.region rast=" + out.name)
                command = "r.out.gdal -c createopt=\"TFW=YES,COMPRESS=LZW\""
                command += " input="
                command += out.name
                command += " output=\"" + filename + "\""
                commands.append(command)
            if isinstance(out, OutputVector):
                command = "v.out.ogr -ce input=" + out.name
                command += " dsn=\"" + os.path.dirname(out.value) + "\""
#.........这里部分代码省略.........
开发者ID:mokerjoke,项目名称:Quantum-GIS,代码行数:103,代码来源:GrassAlgorithm.py


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