import arcgisscripting import os gp = arcgisscripting.create(9.3) gp.Workspace = "H:\\geodata\\" print "Generating list of featureclasses in" " " + gp.Workspace fcList = gp.ListFeatureClasses() for fc in fcList: print fc
You can see the counts of each featureclass in ArcCatalog without any Python scripting. Add features count as a column in the options for display and then touch each featureclass to update the metadata. then when you select the geodatabase or folder the counts will display in the listing.
import arcpy inTable = arcpy.GetParameterAsText(0) result = arcpy.GetCount_management(inTable) print result.getOutput(0)
Thanks Joel for pointing that out. My python scripts seem to break with each new ArcGIS release! It is very time consuming updating even a small number of mission critical python scripts with testing, etc. But with each year I have more and more scripts to maintain.
I found this out when my code failed when we switched to 9.3. I don't remember ESRI announcing this change like they did the change to python lists so it was a little bit of a suprise.Joel
# Using a 9.2-version geoprocessor # import arcgisscripting gp = arcgisscripting.create() gp.workspace = "D:/Workspace" count = gp.GetCount_management("roads")
# Using a 9.3-version geoprocessor # import arcgisscripting gp = arcgisscripting.create(9.3) gp.workspace = "D:/Workspace" result = gp.GetCount_management("roads") count = int(result.GetOutput(0))
import arcgisscripting import os gp = arcgisscripting.create(9.3) gp.Workspace = "H:\\geodata\\" print "Generating list of featureclasses in " + gp.Workspace fcList = gp.ListFeatureClasses() print "Listing all featureclasses in " + gp.Workspace for fc in fcList: print fc print "listing fields in featureclasses" for fc2 in fcList: fn = gp.ListFields(fc2) print str(fc2) + " " + str(len(fn)) print "Counting number of records in each featureclass" for fc3 in fcList: cur = gp.SearchCursor(fc3) row = cur.Next() alist = [] while row: row = cur.Next() alist.append(row) alist.sort() print "number of features in " + fc3 + " are: " + str(len(alist)) del fcList, fc, fc2, fn, cur, row, alist
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.