• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python LayerExporter.LayerExporter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sextante.core.LayerExporter.LayerExporter的典型用法代码示例。如果您正苦于以下问题:Python LayerExporter类的具体用法?Python LayerExporter怎么用?Python LayerExporter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: getSafeExportedLayers

 def getSafeExportedLayers(self):
     '''Returns not the value entered by the user, but a string with semicolon-separated filenames
     which contains the data of the selected layers, but saved in a standard format (currently
     shapefiles for vector layers and GeoTiff for raster) so that they can be opened by most
     external applications.
     If there is a selection and SEXTANTE is configured to use just the selection, if exports
     the layer even if it is already in a suitable format.
     Works only if the layer represented by the parameter value is currently loaded in QGIS.
     Otherwise, it will not perform any export and return the current value string.
     If the current value represents a layer in a suitable format, it does no export at all
     and returns that value.
     Currently, it works just for vector layer. In the case of raster layers, it returns the
     parameter value.
     The layers are exported just the first time the method is called. The method can be called
     several times and it will always return the same string, performing the export only the first time.'''
     if self.exported:
         return self.exported
     self.exported = self.value
     layers = self.value.split(";")
     if layers == None or len(layers) == 0:
         return self.value
     if self.datatype == ParameterMultipleInput.TYPE_RASTER:
         for layerfile in layers:
             layer = QGisLayers.getObjectFromUri(layerfile, False)
             if layer:
                 filename = LayerExporter.exportRasterLayer(layer)
                 self.exported = self.exported.replace(layerfile, filename)
         return self.exported
     else:
         for layerfile in layers:
             layer = QGisLayers.getObjectFromUri(layerfile, False)
             if layer:
                 filename = LayerExporter.exportVectorLayer(layer)
                 self.exported = self.exported.replace(layerfile, filename)
         return self.exported
开发者ID:Nald,项目名称:Quantum-GIS,代码行数:35,代码来源:ParameterMultipleInput.py


示例2: exportVectorLayer

 def exportVectorLayer(self, orgFilename):
     #only export to an intermediate shp if the layer is not file-based.
     #We assume that almost all file formats will be supported by ogr
     #We also export if there is a selection
     if not os.path.exists(orgFilename):
         layer = QGisLayers.getObjectFromUri(orgFilename, False)
         if layer:
             filename = LayerExporter.exportVectorLayer(layer)
     else:
         layer = QGisLayers.getObjectFromUri(orgFilename, False)
         if layer:
             useSelection = SextanteConfig.getSetting(SextanteConfig.USE_SELECTED)
             if useSelection and layer.selectedFeatureCount() != 0:
                 filename = LayerExporter.exportVectorLayer(layer)
             else:
                 filename = orgFilename
         else:
             filename = orgFilename
     destFilename = self.getTempFilename()
     self.exportedLayers[orgFilename]= destFilename
     command = "v.in.ogr"
     command += " min_area=-1"
     command +=" dsn=\"" + os.path.dirname(filename) + "\""
     command +=" layer=" + os.path.basename(filename)[:-4]
     command +=" output=" + destFilename;
     command +=" --overwrite -o"
     return command
开发者ID:mokerjoke,项目名称:Quantum-GIS,代码行数:27,代码来源:GrassAlgorithm.py


示例3: exportVectorLayer

 def exportVectorLayer(self, orgFilename):
     #TODO: improve this. We are now exporting if it is not a shapefile,
     #but the functionality of v.in.ogr could be used for this.
     #We also export if there is a selection
     if not os.path.exists(orgFilename) or not orgFilename.endswith("shp"):
         layer = QGisLayers.getObjectFromUri(orgFilename, False)
         if layer:
             filename = LayerExporter.exportVectorLayer(layer)
     else:
         layer = QGisLayers.getObjectFromUri(orgFilename, False)
         if layer:
             useSelection = SextanteConfig.getSetting(SextanteConfig.USE_SELECTED)
             if useSelection and layer.selectedFeatureCount() != 0:
                 filename = LayerExporter.exportVectorLayer(layer)
             else:
                 filename = orgFilename
         else:
             filename = orgFilename
     destFilename = self.getTempFilename()
     self.exportedLayers[orgFilename]= destFilename
     command = "v.in.ogr"
     min_area = self.getParameterValue(self.GRASS_MIN_AREA_PARAMETER);
     command += " min_area=" + str(min_area)
     snap = self.getParameterValue(self.GRASS_SNAP_TOLERANCE_PARAMETER);
     command += " snap=" + str(snap)
     command += " dsn=\"" + os.path.dirname(filename) + "\""
     command += " layer=" + os.path.basename(filename)[:-4]
     command += " output=" + destFilename;
     command += " --overwrite -o"
     return command
开发者ID:PepSalehi,项目名称:Quantum-GIS,代码行数:30,代码来源:GrassAlgorithm.py


示例4: processAlgorithm

    def processAlgorithm(self, progress):  
        self.createCatalog()   
        inputFilename = self.getParameterValue(self.INPUT)
        layer = QGisLayers.getObjectFromUri(inputFilename)
        workspaceName = self.getParameterValue(self.WORKSPACE)                            
        filename = LayerExporter.exportVectorLayer(layer)            
        basefilename = os.path.basename(filename)
        basepathname = os.path.dirname(filename) + os.sep + basefilename[:basefilename.find('.')]
        connection = {
            'shp': basepathname + '.shp',
            'shx': basepathname + '.shx',
            'dbf': basepathname + '.dbf',
            'prj': basepathname + '.prj'
        }
 
        workspace = self.catalog.get_workspace(workspaceName)
        self.catalog.create_featurestore(basefilename, connection, workspace)
开发者ID:lordi,项目名称:Quantum-GIS,代码行数:17,代码来源:ImportVectorIntoGeoServer.py


示例5: getSafeExportedTable

 def getSafeExportedTable(self):
     '''Returns not the value entered by the user, but a string with a filename which
     contains the data of this table, but saved in a standard format (currently always
     a dbf file) so that it can be opened by most external applications.
     Works only if the table represented by the parameter value is currently loaded in QGIS.
     Otherwise, it will not perform any export and return the current value string.
     If the current value represents a table in a suitable format, it does not export at all
     and returns that value.
     The table is exported just the first time the method is called. The method can be called
     several times and it will always return the same file, performing the export only the first time.'''
     if self.exported:
         return self.exported
     table = QGisLayers.getObjectFromUri(self.value, False)
     if table:
         self.exported = LayerExporter.exportTable(table)
     else:
         self.exported = self.value
     return self.exported
开发者ID:jacklibj,项目名称:readqgis,代码行数:18,代码来源:ParameterTable.py


示例6: getSafeExportedLayer

 def getSafeExportedLayer(self):
     '''Returns not the value entered by the user, but a string with a filename which
     contains the data of this layer, but saved in a standard format (currently always
     a shapefile) so that it can be opened by most external applications.
     If there is a selection and SEXTANTE is configured to use just the selection, if exports
     the layer even if it is already in a suitable format.
     Works only if the layer represented by the parameter value is currently loaded in QGIS.
     Otherwise, it will not perform any export and return the current value string.
     If the current value represents a layer in a suitable format, it does not export at all
     and returns that value.
     The layer is exported just the first time the method is called. The method can be called
     several times and it will always return the same file, performing the export only the first time.'''
     if self.exported:
         return self.exported
     layer = QGisLayers.getObjectFromUri(self.value, False)
     if layer:
         self.exported = LayerExporter.exportVectorLayer(layer)
     else:
         self.exported = self.value
     return self.exported
开发者ID:mokerjoke,项目名称:Quantum-GIS,代码行数:20,代码来源:ParameterVector.py


示例7: processAlgorithm

    def processAlgorithm(self, progress):
        if SextanteUtils.isWindows():
            path = SagaUtils.sagaPath()
            if path == "":
                raise GeoAlgorithmExecutionException("SAGA folder is not configured.\nPlease configure it before running SAGA algorithms.")
        commands = list()
        self.exportedLayers = {}

        #1: Export rasters to sgrd and vectors to shp
        #   Tables must be in dbf format. We check that.
        if self.resample:
            self.calculateResamplingExtent()
        for param in self.parameters:
            if isinstance(param, ParameterRaster):
                if param.value == None:
                    continue
                value = param.value
                if not value.endswith("sgrd"):
                    commands.append(self.exportRasterLayer(value))
                if self.resample:
                    commands.append(self.resampleRasterLayer(value));
            if isinstance(param, ParameterVector):
                if param.value == None:
                    continue
                layer = QGisLayers.getObjectFromUri(param.value, False)
                if layer:
                    filename = LayerExporter.exportVectorLayer(layer)
                    self.exportedLayers[param.value]=filename
                elif not param.value.endswith("shp"):
                        raise GeoAlgorithmExecutionException("Unsupported file format")
            if isinstance(param, ParameterTable):
                if param.value == None:
                    continue
                table = QGisLayers.getObjectFromUri(param.value, False)
                if table:
                    filename = LayerExporter.exportTable(table)
                    self.exportedLayers[param.value]=filename
                elif not param.value.endswith("shp"):
                        raise GeoAlgorithmExecutionException("Unsupported file format")
            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 layerfile in layers:
                        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
        if SextanteUtils.isWindows():
            command = self.undecoratedGroup  + " \"" + self.cmdname + "\""
        else:
            command = "lib" + self.undecoratedGroup  + " \"" + self.cmdname + "\""

        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  = SextanteUtils.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]));
#.........这里部分代码省略.........
开发者ID:badcock4412,项目名称:Quantum-GIS,代码行数:101,代码来源:SagaAlgorithm.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python QGisLayers.QGisLayers类代码示例发布时间:2022-05-27
下一篇:
Python GeoAlgorithm.GeoAlgorithm类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap