本文整理汇总了Python中sextante.core.SextanteUtils.SextanteUtils类的典型用法代码示例。如果您正苦于以下问题:Python SextanteUtils类的具体用法?Python SextanteUtils怎么用?Python SextanteUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SextanteUtils类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: initializeSettings
def initializeSettings(self):
AlgorithmProvider.initializeSettings(self)
if SextanteUtils.isWindows() or SextanteUtils.isMac():
SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_FOLDER, "GRASS folder", GrassUtils.grassPath()))
SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_WIN_SHELL, "Msys folder", GrassUtils.grassWinShell()))
SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_LOG_COMMANDS, "Log execution commands", False))
SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_LOG_CONSOLE, "Log console output", False))
开发者ID:JoeyPinilla,项目名称:Quantum-GIS,代码行数:7,代码来源:GrassAlgorithmProvider.py
示例2: unload
def unload(self):
AlgorithmProvider.unload(self)
if SextanteUtils.isWindows() or SextanteUtils.isMac():
SextanteConfig.removeSetting(GrassUtils.GRASS_FOLDER)
SextanteConfig.removeSetting(GrassUtils.GRASS_WIN_SHELL)
SextanteConfig.removeSetting(GrassUtils.GRASS_LOG_COMMANDS)
SextanteConfig.removeSetting(GrassUtils.GRASS_LOG_CONSOLE)
开发者ID:JoeyPinilla,项目名称:Quantum-GIS,代码行数:7,代码来源:GrassAlgorithmProvider.py
示例3: 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
示例4: exportRasterLayer
def exportRasterLayer(self, layer):
destFilename = SextanteUtils.getTempFilename("sgrd")
self.exportedLayers[layer]= destFilename
if SextanteUtils.isWindows():
return "io_gdal 0 -GRIDS \"" + destFilename + "\" -FILES \"" + layer+"\""
else:
return "libio_gdal 0 -GRIDS \"" + destFilename + "\" -FILES \"" + layer + "\""
开发者ID:badcock4412,项目名称:Quantum-GIS,代码行数:7,代码来源:SagaAlgorithm.py
示例5: otbPath
def otbPath():
folder = SextanteConfig.getSetting(OTBUtils.OTB_FOLDER)
if folder == None:
folder = ""
#try to configure the path automatically
if SextanteUtils.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 SextanteUtils.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:geodenilson,项目名称:Quantum-GIS,代码行数:25,代码来源:OTBUtils.py
示例6: checkBeforeOpeningParametersDialog
def checkBeforeOpeningParametersDialog(self):
if SextanteUtils.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 settings.contains(R_INSTALLED):
return
if SextanteUtils.isWindows():
if SextanteConfig.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
return "It seems that R is not correctly installed in your system.\nPlease install it before running R Scripts."
开发者ID:JoeyPinilla,项目名称:Quantum-GIS,代码行数:25,代码来源:RAlgorithm.py
示例7: processAlgorithm
def processAlgorithm(self, progress):
#TODO:check correct num of bands
input = self.getParameterValue(SplitRGBBands.INPUT)
temp = SextanteUtils.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 SextanteUtils.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:Adam-Brown,项目名称:Quantum-GIS,代码行数:26,代码来源:SplitRGBBands.py
示例8: checkRIsInstalled
def checkRIsInstalled(ignoreRegistrySettings=False):
if SextanteUtils.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 SextanteUtils.isWindows():
if SextanteConfig.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/sextante/3rdParty.html">Click here</a>'
'to know more about how to install and configure R to be used with SEXTANTE</p>')
return html
开发者ID:Adam-Brown,项目名称:Quantum-GIS,代码行数:30,代码来源:RUtils.py
示例9: sagaBatchJobFilename
def sagaBatchJobFilename():
if SextanteUtils.isWindows():
filename = "saga_batch_job.bat";
else:
filename = "saga_batch_job.sh";
batchfile = SextanteUtils.userFolder() + os.sep + filename
return batchfile
开发者ID:geonux,项目名称:Quantum-GIS,代码行数:10,代码来源:SagaUtils.py
示例10: initializeSettings
def initializeSettings(self):
AlgorithmProvider.initializeSettings(self)
if SextanteUtils.isWindows():
SextanteConfig.addSetting(
Setting(self.getDescription(), SagaUtils.SAGA_FOLDER, "SAGA folder", SagaUtils.sagaPath())
)
SextanteConfig.addSetting(
Setting(
self.getDescription(),
SagaUtils.SAGA_AUTO_RESAMPLING,
"Use min covering grid system for resampling",
True,
)
)
SextanteConfig.addSetting(
Setting(self.getDescription(), SagaUtils.SAGA_LOG_COMMANDS, "Log execution commands", False)
)
SextanteConfig.addSetting(
Setting(self.getDescription(), SagaUtils.SAGA_LOG_CONSOLE, "Log console output", False)
)
SextanteConfig.addSetting(
Setting(self.getDescription(), SagaUtils.SAGA_RESAMPLING_REGION_XMIN, "Resampling region min x", 0)
)
SextanteConfig.addSetting(
Setting(self.getDescription(), SagaUtils.SAGA_RESAMPLING_REGION_YMIN, "Resampling region min y", 0)
)
SextanteConfig.addSetting(
Setting(self.getDescription(), SagaUtils.SAGA_RESAMPLING_REGION_XMAX, "Resampling region max x", 1000)
)
SextanteConfig.addSetting(
Setting(self.getDescription(), SagaUtils.SAGA_RESAMPLING_REGION_YMAX, "Resampling region max y", 1000)
)
SextanteConfig.addSetting(
Setting(self.getDescription(), SagaUtils.SAGA_RESAMPLING_REGION_CELLSIZE, "Resampling region cellsize", 1)
)
开发者ID:rudivs,项目名称:Quantum-GIS,代码行数:35,代码来源:SagaAlgorithmProvider.py
示例11: unload
def unload(self):
self.toolbox.setVisible(False)
self.menu.deleteLater()
#delete temporary output files
folder = SextanteUtils.tempFolder()
if QDir(folder).exists():
shutil.rmtree(folder, True)
开发者ID:L-Infantini,项目名称:Quantum-GIS,代码行数:7,代码来源:SextantePlugin.py
示例12: scriptsFolder
def scriptsFolder():
folder = SextanteConfig.getSetting(ScriptUtils.SCRIPTS_FOLDER)
if folder == None:
folder = SextanteUtils.userFolder() + os.sep + "scripts"
mkdir(folder)
return folder
开发者ID:hCivil,项目名称:Quantum-GIS,代码行数:7,代码来源:ScriptUtils.py
示例13: 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
示例14: modelsFolder
def modelsFolder():
folder = SextanteConfig.getSetting(ModelerUtils.MODELS_FOLDER)
if folder == None:
folder = unicode(os.path.join(SextanteUtils.userFolder(), "models"))
mkdir(folder)
return os.path.abspath(folder)
开发者ID:Adam-Brown,项目名称:Quantum-GIS,代码行数:7,代码来源:ModelerUtils.py
示例15: exportVectorLayer
def exportVectorLayer(layer):
'''Takes a QgsVectorLayer 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, or if there is a selection and it should be
used, exporting just the selected features.
Currently, the output is restricted to shapefiles, so anything that is not in a shapefile
will get exported.
It also export to a new file if the original one contains non-ascii characters'''
settings = QSettings()
systemEncoding = settings.value( "/UI/encoding", "System" ).toString()
output = SextanteUtils.getTempFilename("shp")
provider = layer.dataProvider()
useSelection = SextanteConfig.getSetting(SextanteConfig.USE_SELECTED)
if useSelection and layer.selectedFeatureCount() != 0:
writer = QgsVectorFileWriter(output, systemEncoding, layer.pendingFields(), provider.geometryType(), layer.crs())
selection = layer.selectedFeatures()
for feat in selection:
writer.addFeature(feat)
del writer
return output
else:
isASCII=True
try:
unicode(layer.source()).decode("ascii")
except UnicodeEncodeError:
isASCII=False
if (not unicode(layer.source()).endswith("shp") or not isASCII):
writer = QgsVectorFileWriter( output, systemEncoding, layer.pendingFields(), provider.geometryType(), layer.crs() )
for feat in layer.getFeatures():
writer.addFeature(feat)
del writer
return output
else:
return unicode(layer.source())
开发者ID:jacklibj,项目名称:readqgis,代码行数:35,代码来源:LayerExporter.py
示例16: 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 = SextanteUtils.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:Adam-Brown,项目名称:Quantum-GIS,代码行数:29,代码来源:LayerExporter.py
示例17: exportVectorLayer
def exportVectorLayer(layer):
'''Takes a QgsVectorLayer 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, or if there is a selection and it should be
used, exporting just the selected features.
Currently, the output is restricted to shapefiles, so anything that is not in a shapefile
will get exported'''
settings = QSettings()
systemEncoding = settings.value( "/UI/encoding", "System" ).toString()
output = SextanteUtils.getTempFilename("shp")
provider = layer.dataProvider()
allAttrs = provider.attributeIndexes()
provider.select( allAttrs )
useSelection = SextanteConfig.getSetting(SextanteConfig.USE_SELECTED)
if useSelection and layer.selectedFeatureCount() != 0:
writer = QgsVectorFileWriter( output, systemEncoding,provider.fields(), provider.geometryType(), provider.crs() )
selection = layer.selectedFeatures()
for feat in selection:
writer.addFeature(feat)
del writer
return output
else:
if (not unicode(layer.source()).endswith("shp")):
writer = QgsVectorFileWriter( output, systemEncoding,provider.fields(), provider.geometryType(), provider.crs() )
feat = QgsFeature()
while provider.nextFeature(feat):
writer.addFeature(feat)
del writer
return output
else:
return unicode(layer.source())
开发者ID:mokerjoke,项目名称:Quantum-GIS,代码行数:32,代码来源:LayerExporter.py
示例18: test_SagaVectorAlgorithWithUnsupportedInputAndOutputFormat
def test_SagaVectorAlgorithWithUnsupportedInputAndOutputFormat(self):
'''this tests both the exporting to shp and then the format change in the output layer'''
layer = sextante.getobject(polygonsGeoJson());
feature = layer.getFeatures().next()
selected = [feature.id()]
layer.setSelectedFeatures(selected)
outputs=sextante.runalg("saga:polygoncentroids",polygonsGeoJson(),True, SextanteUtils.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=sextante.getfeatures(layer)
self.assertEqual(1, len(features))
feature=features.next()
attrs=feature.attributes()
expectedvalues=["0","1.1","string a"]
values=[str(attr.toString()) for attr in attrs]
self.assertEqual(expectedvalues, values)
wkt='POINT(270787.49991451 4458955.46775295)'
self.assertEqual(wkt, str(feature.geometry().exportToWkt()))
开发者ID:Hardysong,项目名称:Quantum-GIS,代码行数:26,代码来源:SagaTest.py
示例19: test_SagaRasterAlgorithmWithUnsupportedOutputFormat
def test_SagaRasterAlgorithmWithUnsupportedOutputFormat(self):
outputs=sextante.runalg("saga:convergenceindex",raster(),0,0,SextanteUtils.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:Hardysong,项目名称:Quantum-GIS,代码行数:7,代码来源:SagaTest.py
示例20: modelsFolder
def modelsFolder():
folder = SextanteConfig.getSetting(ModelerUtils.MODELS_FOLDER)
if folder == None:
folder = SextanteUtils.userFolder() + os.sep + "models"
mkdir(folder)
return folder
开发者ID:hCivil,项目名称:Quantum-GIS,代码行数:7,代码来源:ModelerUtils.py
注:本文中的sextante.core.SextanteUtils.SextanteUtils类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论