Creates a list of the unique code occurrences and their frequency for a specified set of items in an table.
Frequency_analysis (in_table, out_table, frequency_fields, summary_fields)
Data types for geoprocessing tool parametersScript Example
|Input Table (Required)
The table containing the field(s) that will be used to calculate frequency statistics. It can be an INFO or OLE DB table, a dBASE or a VPF table, or a feature class.
|Table View | Raster Layer
|Output Table (Required)
The table that will store the calculated frequency statistics.
|Frequency Field(s) (Required)
The attribute field or fields that will be used to calculate frequency statistics.
|Summary Field(s) (Optional)
The attribute field or fields to sum and add to the output table. Null values are excluded from this calculation.
# Purpose: Break all multipart features into singlepart features,
# and generate a report of which features were separated.
# Create the geoprocessor
gp = arcgisscripting.create()
# Create variables for the input and output feature classes
inFeatureClass = "c:/gdb.mdb/vegetation"
outFeatureClass = "c:/gdb.mdb/vegetation_singlepart"
# Use error trapping in case a problem occurs when running the tool
# Add a field to the input (if not already present), this will be used as a unique identifier
if not gp.ListFields(inFeatureClass,"tmpUID").Next():
# Determine what the name of the Object ID is
fields = gp.listfields(inFeatureClass, "","oid")
OidFieldName = fields.next().name
# Calculate the tmpUID to the OID since this is a Personal GDB, wrap the Field inside 
exp = "[" + OidFieldName + "]"
gp.CalculateField(inFeatureClass, "tmpUID", exp)
# Run the tool to create a new fc with only singlepart features
# Check if there is a different number of features in the output than there was in the input
if (gp.GetCount(inFeatureClass) == (gp.GetCount(outFeatureClass))):
print "The number of features in the input is the same as in the output, so no multipart features were found"
# If there is a difference, print out the FID of the input features which were multipart
gp.Frequency(outFeatureClass, outFeatureClass + "_freq", "tmpUID")
# Use a search cursor to go through the table, and print the tmpUID
print "Below is a list of the FIDs of all the multipart features from " + inFeatureClass
rows = gp.SearchCursor(outFeatureClass + "_freq", "[FREQUENCY] > 1")
row = rows.next()
row = rows.next()
# If an error occurred, print out the error message
print "Error occurred"