本文整理汇总了Python中processing.core.ProcessingUtils.ProcessingUtils.tempFolder方法的典型用法代码示例。如果您正苦于以下问题:Python ProcessingUtils.tempFolder方法的具体用法?Python ProcessingUtils.tempFolder怎么用?Python ProcessingUtils.tempFolder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类processing.core.ProcessingUtils.ProcessingUtils
的用法示例。
在下文中一共展示了ProcessingUtils.tempFolder方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: unload
# 需要导入模块: from processing.core.ProcessingUtils import ProcessingUtils [as 别名]
# 或者: from processing.core.ProcessingUtils.ProcessingUtils import tempFolder [as 别名]
def unload(self):
self.toolbox.setVisible(False)
self.menu.deleteLater()
#delete temporary output files
folder = ProcessingUtils.tempFolder()
if QDir(folder).exists():
shutil.rmtree(folder, True)
self.iface.unregisterMainWindowAction(self.commanderAction)
示例2: getHtmlFile
# 需要导入模块: from processing.core.ProcessingUtils import ProcessingUtils [as 别名]
# 或者: from processing.core.ProcessingUtils.ProcessingUtils import tempFolder [as 别名]
def getHtmlFile(self, alg, helpFile):
if not os.path.exists(helpFile):
return None
self.alg = alg
f = open(helpFile, "rb")
self.descriptions = pickle.load(f)
s = "<h2>Algorithm description</h2>\n"
s += "<p>" + self.getDescription(self.ALG_DESC) + "</p>\n"
s += "<h2>Input parameters</h2>\n"
for param in self.alg.parameters:
s += "<h3>" + param.description + "</h3>\n"
s += "<p>" + self.getDescription(param.name) + "</p>\n"
s += "<h2>Outputs</h2>\n"
for out in self.alg.outputs:
s += "<h3>" + out.description + "</h3>\n"
s += "<p>" + self.getDescription(out.name) + "</p>\n"
filename = ProcessingUtils.tempFolder() + os.sep + "temphelp.html"
tempHtml = open(filename, "w")
tempHtml.write(s)
return filename
示例3: processAlgorithm
# 需要导入模块: from processing.core.ProcessingUtils import ProcessingUtils [as 别名]
# 或者: from processing.core.ProcessingUtils.ProcessingUtils import tempFolder [as 别名]
#.........这里部分代码省略.........
if not layerfile.endswith("sgrd"):
commands.append(self.exportRasterLayer(layerfile))
if self.resample:
commands.append(self.resampleRasterLayer(layerfile));
elif param.datatype == ParameterMultipleInput.TYPE_VECTOR_ANY:
for layerfile in layers:
layer = QGisLayers.getObjectFromUri(layerfile, False)
if layer:
filename = LayerExporter.exportVectorLayer(layer)
self.exportedLayers[layerfile]=filename
elif (not layerfile.endswith("shp")):
raise GeoAlgorithmExecutionException("Unsupported file format")
#2: set parameters and outputs
saga208 = ProcessingConfig.getSetting(SagaUtils.SAGA_208)
if ProcessingUtils.isWindows() or ProcessingUtils.isMac() or not saga208:
command = self.undecoratedGroup + " \"" + self.cmdname + "\""
else:
command = "lib" + self.undecoratedGroup + " \"" + self.cmdname + "\""
if self.hardcodedStrings:
for s in self.hardcodedStrings:
command += " " + s
for param in self.parameters:
if param.value is None:
continue
if isinstance(param, (ParameterRaster, ParameterVector, ParameterTable)):
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])
command += (" -" + param.name + " \"" + s + "\"");
elif isinstance(param, ParameterBoolean):
if param.value:
command+=(" -" + param.name);
elif isinstance(param, ParameterFixedTable):
tempTableFile = ProcessingUtils.getTempFilename("txt")
f = open(tempTableFile, "w")
f.write('\t'.join([col for col in param.cols]) + "\n")
values = param.value.split(",")
for i in range(0, len(values), 3):
s = values[i] + "\t" + values[i+1] + "\t" + values[i+2] + "\n"
f.write(s)
f.close()
command+=( " -" + param.name + " \"" + tempTableFile + "\"")
elif isinstance(param, ParameterExtent):
#'we have to substract/add half cell size, since saga is center based, not corner based
halfcell = self.getOutputCellsize() / 2
offset = [halfcell, -halfcell, halfcell, -halfcell]
values = param.value.split(",")
for i in range(4):
command+=(" -" + self.extentParamNames[i] + " " + str(float(values[i]) + offset[i]));
elif isinstance(param, (ParameterNumber, ParameterSelection)):
command+=(" -" + param.name + " " + str(param.value));
else:
command+=(" -" + param.name + " \"" + str(param.value) + "\"");
for out in self.outputs:
if isinstance(out, OutputRaster):
filename = out.getCompatibleFileName(self)
filename = ProcessingUtils.tempFolder() + os.sep + os.path.basename(filename) + ".sgrd"
command+=(" -" + out.name + " \"" + filename + "\"");
if isinstance(out, OutputVector):
filename = out.getCompatibleFileName(self)
command+=(" -" + out.name + " \"" + filename + "\"");
if isinstance(out, OutputTable):
filename = out.getCompatibleFileName(self)
command+=(" -" + out.name + " \"" + filename + "\"");
commands.append(command)
#3:Export resulting raster layers
for out in self.outputs:
if isinstance(out, OutputRaster):
filename = out.getCompatibleFileName(self)
filename2 = ProcessingUtils.tempFolder() + os.sep + os.path.basename(filename) + ".sgrd"
formatIndex = 1 if saga208 else 4
if ProcessingUtils.isWindows() or ProcessingUtils.isMac() or not saga208:
commands.append("io_gdal 1 -GRIDS \"" + filename2 + "\" -FORMAT " + str(formatIndex) +" -TYPE 0 -FILE \"" + filename + "\"");
else:
commands.append("libio_gdal 1 -GRIDS \"" + filename2 + "\" -FORMAT 1 -TYPE 0 -FILE \"" + filename + "\"");
#4 Run SAGA
commands = self.editCommands(commands)
SagaUtils.createSagaBatchJobFileFromSagaCommands(commands)
loglines = []
loglines.append("SAGA execution commands")
for line in commands:
progress.setCommand(line)
loglines.append(line)
if ProcessingConfig.getSetting(SagaUtils.SAGA_LOG_COMMANDS):
ProcessingLog.addToLog(ProcessingLog.LOG_INFO, loglines)
SagaUtils.executeSaga(progress);
示例4: initialize
# 需要导入模块: from processing.core.ProcessingUtils import ProcessingUtils [as 别名]
# 或者: from processing.core.ProcessingUtils.ProcessingUtils import tempFolder [as 别名]
def initialize():
icon = QtGui.QIcon(os.path.dirname(__file__) + "/../images/alg.png")
ProcessingConfig.settingIcons["General"] = icon
ProcessingConfig.addSetting(
Setting("General", ProcessingConfig.USE_THREADS, "Run algorithms in a new thread", True)
)
ProcessingConfig.addSetting(
Setting(
"General",
ProcessingConfig.SHOW_DEBUG_IN_DIALOG,
"Show extra info in Log panel (threaded execution only)",
True,
)
)
ProcessingConfig.addSetting(
Setting("General", ProcessingConfig.KEEP_DIALOG_OPEN, "Keep dialog open after running an algorithm", False)
)
ProcessingConfig.addSetting(
Setting("General", ProcessingConfig.USE_SELECTED, "Use only selected features", True)
)
ProcessingConfig.addSetting(
Setting("General", ProcessingConfig.TABLE_LIKE_PARAM_PANEL, "Show table-like parameter panels", False)
)
ProcessingConfig.addSetting(
Setting("General", ProcessingConfig.USE_FILENAME_AS_LAYER_NAME, "Use filename as layer name", False)
)
ProcessingConfig.addSetting(
Setting("General", ProcessingConfig.SHOW_RECENT_ALGORITHMS, "Show recently executed algorithms", True)
)
ProcessingConfig.addSetting(
Setting("General", ProcessingConfig.OUTPUT_FOLDER, "Output folder", ProcessingUtils.tempFolder())
)
ProcessingConfig.addSetting(
Setting("General", ProcessingConfig.SHOW_CRS_DEF, "Show layer CRS definition in selection boxes", True)
)
ProcessingConfig.addSetting(
Setting(
"General",
ProcessingConfig.WARN_UNMATCHING_CRS,
"Warn before executing if layer CRS's do not match",
True,
)
)
ProcessingConfig.addSetting(Setting("General", ProcessingConfig.RASTER_STYLE, "Style for raster layers", ""))
ProcessingConfig.addSetting(
Setting("General", ProcessingConfig.VECTOR_POINT_STYLE, "Style for point layers", "")
)
ProcessingConfig.addSetting(Setting("General", ProcessingConfig.VECTOR_LINE_STYLE, "Style for line layers", ""))
ProcessingConfig.addSetting(
Setting("General", ProcessingConfig.VECTOR_POLYGON_STYLE, "Style for polygon layers", "")
)
ProcessingConfig.addSetting(
Setting("General", ProcessingConfig.VECTOR_POLYGON_STYLE, "Style for polygon layers", "")
)
ProcessingConfig.addSetting(
Setting("General", ProcessingConfig.PRE_EXECUTION_SCRIPT, "Pre-execution script", "")
)
ProcessingConfig.addSetting(
Setting("General", ProcessingConfig.POST_EXECUTION_SCRIPT, "Post-execution script", "")
)
ProcessingConfig.addSetting(
Setting("General", ProcessingConfig.RECENT_ALGORITHMS, "Recent algs", "", hidden=True)
)
示例5: grassDataFolder
# 需要导入模块: from processing.core.ProcessingUtils import ProcessingUtils [as 别名]
# 或者: from processing.core.ProcessingUtils.ProcessingUtils import tempFolder [as 别名]
def grassDataFolder():
tempfolder = os.path.join(ProcessingUtils.tempFolder(), "grassdata")
mkdir(tempfolder)
return tempfolder