本文整理汇总了Python中sextante.core.SextanteUtils.SextanteUtils.getTempFilenameInTempFolder方法的典型用法代码示例。如果您正苦于以下问题:Python SextanteUtils.getTempFilenameInTempFolder方法的具体用法?Python SextanteUtils.getTempFilenameInTempFolder怎么用?Python SextanteUtils.getTempFilenameInTempFolder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sextante.core.SextanteUtils.SextanteUtils
的用法示例。
在下文中一共展示了SextanteUtils.getTempFilenameInTempFolder方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: exportRasterLayer
# 需要导入模块: from sextante.core.SextanteUtils import SextanteUtils [as 别名]
# 或者: from sextante.core.SextanteUtils.SextanteUtils import getTempFilenameInTempFolder [as 别名]
def exportRasterLayer(self, layer):
destFilename = SextanteUtils.getTempFilenameInTempFolder(os.path.basename(layer)[0:5] + ".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 + "\""
示例2: exportVectorLayer
# 需要导入模块: from sextante.core.SextanteUtils import SextanteUtils [as 别名]
# 或者: from sextante.core.SextanteUtils.SextanteUtils import getTempFilenameInTempFolder [as 别名]
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" )
filename = os.path.basename(unicode(layer.source()))
idx = filename.rfind(".")
if idx != -1:
filename = filename[:idx]
filename = str(layer.name())
validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:"
filename = ''.join(c for c in filename if c in validChars)
if len(filename) == 0:
filename = "layer"
output = SextanteUtils.getTempFilenameInTempFolder(filename + ".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())