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


Python arcpy.ListFeatureClasses方法代码示例

本文整理汇总了Python中arcpy.ListFeatureClasses方法的典型用法代码示例。如果您正苦于以下问题:Python arcpy.ListFeatureClasses方法的具体用法?Python arcpy.ListFeatureClasses怎么用?Python arcpy.ListFeatureClasses使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在arcpy的用法示例。


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

示例1: getFC

# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import ListFeatureClasses [as 别名]
def getFC(ws, fc_name, fds=""):
    fc_list = arcpy.ListFeatureClasses("*" + fc_name, feature_dataset=fds)
    if not fc_list:
        fc = ""
        arcpy.AddWarning(fc_name + " not found in " + ws + ".")
    else:
        fc = os.path.join(ws, fds, fc_list[0])
    return fc 
开发者ID:Esri,项目名称:maritime-charting-sample-scripts,代码行数:10,代码来源:s57_2_chart.py

示例2: GetFieldInfo

# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import ListFeatureClasses [as 别名]
def GetFieldInfo(gdb):
    # Not being used any more.
    #
    # Assumption is that this is all dictated by the XML Workspace document so schema problems
    # should not occur as long as the standard tools were used to create all databases.
    #
    # Create standard schema description for each geodatabase and use it in comparison
    # to the rest of the tables

    try:
        env.workspace = gdb
        tblList = arcpy.ListTables()
        tblList.extend(arcpy.ListFeatureClasses())
        tblList.extend(arcpy.ListRasters())
        dSchema = dict()
        arcpy.SetProgressorLabel("Reading geodatabase schema...")
        arcpy.SetProgressor("step", "Reading geodatabase schema...",  0, len(tblList), 1)

        for tbl in tblList:
            tblName = tbl.encode('ascii').upper()
            arcpy.SetProgressorLabel("Reading schema for " + os.path.basename(gdb) + ": " + tblName )
            desc = arcpy.Describe(tblName)
            fields = desc.fields
            stdSchema = list()

            for fld in fields:
                stdSchema.append((fld.baseName.encode('ascii').upper(), fld.length, fld.precision, fld.scale, fld.type.encode('ascii').upper()))
                #stdSchema.append((fld.baseName.encode('ascii').upper(), fld.length, fld.precision, fld.scale, fld.type.encode('ascii').upper(), fld.aliasName.encode('ascii').upper()))

            dSchema[tblName] = stdSchema
            arcpy.SetProgressorPosition()

        arcpy.ResetProgressor()
        return dSchema

    except:
        errorMsg()
        return dict()

## =================================================================================== 
开发者ID:ncss-tech,项目名称:geo-pit,代码行数:42,代码来源:SSURGO_CheckgSSURGO2.py

示例3: WriteCSV

# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import ListFeatureClasses [as 别名]
def WriteCSV(self):
        # This function writes the CSV. It writes the header then the rows. This script omits the SHAPE fields.
        try:
            env.workspace = self._tempWorkspace

            #fc = arcpy.ListFeatureClasses(self._layers)
            # for fcs in self._layer:
            fcs = self._layer
            if arcpy.Exists(fcs):
                with open(self._CSVLocation, 'wb') as outFile:
                    print "%s create" % self._CSVLocation
                    linewriter = csv.writer(outFile, delimiter = ',')

                    fcdescribe = arcpy.Describe(fcs)
                    flds = fcdescribe.Fields

                    # skip shape fields and derivatives
                    attrs = ("areaFieldName", "lengthFieldName", "shapeFieldName")
                    resFields = [getattr(fcdescribe, attr) for attr in attrs
                                    if hasattr(fcdescribe, attr)]

                    header,fldLst = zip(*((fld.AliasName, fld.name) for fld in flds
                                            if fld.name not in resFields))

                    linewriter.writerow([h.encode('utf8') if isinstance(h, unicode) else h for h in header])
                    linewriter.writerows([[r.encode('utf8') if isinstance(r, unicode) else r for r in row]
                                            for row in arcpy.da.SearchCursor(fcs, fldLst)])

                print "CSV file complete"
            return True
        except arcpy.ExecuteError:
            line, filename, synerror = trace()
            raise ReportToolsError({
                "function": "create_report_layers_using_config",
                "line": line,
                "filename":  filename,
                "synerror": synerror,
                "arcpyError": arcpy.GetMessages(2),
            }
            )
        except:
            line, filename, synerror = trace()
            raise ReportToolsError({
                "function": "create_report_layers_using_config",
                "line": line,
                "filename":  filename,
                "synerror": synerror,
            }
            ) 
开发者ID:Esri,项目名称:utilities-solution-data-automation,代码行数:51,代码来源:csvexport.py

示例4: get_feature_classes

# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import ListFeatureClasses [as 别名]
def get_feature_classes(self):
        """Get geodatabase feature classes as ordered dicts."""
        fcs = []
        if self.arcpy_found:
            arcpy.env.workspace = self.path
            # iterate feature classes within feature datasets
            fds = [fd for fd in arcpy.ListDatasets(feature_type='feature')]
            if fds:
                for fd in fds:
                    arcpy.env.workspace = os.path.join(self.path, fd)
                    for fc in arcpy.ListFeatureClasses():
                        od = self._get_fc_props(fc)
                        od['Feature dataset'] = fd
                        fcs.append(od)

            # iterate feature classes in the geodatabase root
            arcpy.env.workspace = self.path
            for fc in arcpy.ListFeatureClasses():
                od = self._get_fc_props(fc)
                fcs.append(od)

        else:
            ds = ogr.Open(self.path, 0)
            fcs_names = [
                ds.GetLayerByIndex(i).GetName()
                for i in range(0, ds.GetLayerCount())
                if ds.GetLayerByIndex(i).GetGeometryColumn()
            ]
            for fc_name in fcs_names:
                try:
                    fc_instance = FeatureClassOgr(self, fc_name)
                    od = OrderedDict()
                    for k, v in GDB_FC_PROPS.items():
                        od[v] = getattr(fc_instance, k, '')
                    # custom props
                    od['Row count'] = fc_instance.get_row_count()
                    fcs.append(od)
                except Exception as e:
                    print(e)
        return fcs

    # ---------------------------------------------------------------------- 
开发者ID:AlexArcPy,项目名称:registrant,代码行数:44,代码来源:_geodatabase.py


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