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


Python SextanteUtils.getTempFilenameInTempFolder方法代码示例

本文整理汇总了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 + "\""
开发者ID:jesusjl,项目名称:Quantum-GIS,代码行数:9,代码来源:SagaAlgorithm.py

示例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())
开发者ID:Adam-Brown,项目名称:Quantum-GIS,代码行数:48,代码来源:LayerExporter.py


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