测试结果如下:从测试结果可以看到,随着gdb中的图层个数增加,arcpy.ListFeatureClasses()函数耗时也越来越长。 脚本工具随着运行越来越慢的最大的问题是在循环中使用了arcpy.ListFeatureClasses()函数;这个函数的作用是获取工作空间中FeatureClass的图层名称列表,拿到这个图层名称列表后就可以去遍历读取这个gdb数据库中对应...
The list containing feature class names is returned from the function, limited by the optional wild_card, feature_type, and feature_dataset arguments. コードのサンプル ListFeatureClasses example Copy shapefiles to a geodatabase. import os import arcpy # Set the workspace for ListFeatureClass...
("*", "FileGDB"): arcpy.env.workspace = ws # feature classes for fc in arcpy.ListFeatureClasses(): print fc # tables for tbl in arcpy.ListTables(): print tbl # feature classes in datasets for ds in arcpy.ListDatasets(): arcpy.env.workspace = ds for dfc in arcpy.ListFeatureClasses...
fields = arcpy.ListFields("c:/data/municipal.gdb/hospitals") for field in fields: print("{0} is a type of {1} with a length of {2}" .format(field.name, field.type, field.length)) ListFields 示例 2 生成字段名称列表。 import arcpy featureclass = "c:/data/municipal.gdb/hospitals...
import arcpy featureclass = "c:/data/roads.shp" # Get list of indexes for roads.shp and print properties indexes = arcpy.ListIndexes(featureclass) for index in indexes: print("Name : {0}".format(index.name)) print("IsAscending : {0}".format(index.isAscending)) print("IsUnique : {...
String wild_card wild_card可限制返回的结果。如果未指定任何wild_card,则会返回所有值。 String 返回值 数据类型说明 Index 返回包含索引对象的列表。 代码示例 ListIndexes 示例 列出索引属性。 importarcpyfeatureclass="c:/data/roads.shp"# Get list of indexes for roads.shp and print propertiesindexes=arcp...
If your fields change between featureclasses, and the sql needs to change between each featureclass, you can use if/elif to create your sql. arcpy.env.overwriteOutput=True#<- move to top of script since it only needs to be set onceforfcinfcs2:# fichier temporaire d'affinag...
importarcpyfeatureclass="c:/data/roads.shp"# Get list of indexes for roads.shp and print propertiesindexes=arcpy.ListIndexes(featureclass)forindexinindexes:print("Name : {0}".format(index.name))print("IsAscending : {0}".format(index.isAscending))print("IsUnique : {0}".format(index.isUn...
importarcpy featureclass ="c:/data/roads.shp"# Get list of indexes for roads.shp and print propertiesindexes = arcpy.ListIndexes(featureclass)forindexinindexes: print("Name : {0}".format(index.name)) print("IsAscending : {0}".format(index.isAscending)) print("IsUnique : {0}".format...
import arcpy fields = arcpy.ListFields('Feature Class Name') print(len(fields)) Note: Do not remove the single quotation marks enclosing the feature class name. In this example, the feature class is Asia. Place the cursor at the end of the expression and pressEntertwice on the ...