Show Navigation | Hide Navigation
You are here:
Geoprocessing tool reference > Analysis toolbox > Statistics toolset > Tools

Frequency (Analysis) (ArcInfo only)

Release 9.2
Last modified January 13, 2009
E-mail This Topic Printable Version Give Us Feedback

Print all topics in : "Tools"


Related Topics

Creates a list of the unique code occurrences and their frequency for a specified set of items in an table.


Usage tips

Command line syntax
An overview of the Command Line window
Frequency_analysis <in_table> <out_table> <frequency_fields; frequency_fields...> {summary_fields; summary_fields...}

Parameter Explanation Data Type
<in_table>

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
<out_table>

The table that will store the calculated frequency statistics.

Table
<frequency_fields; frequency_fields...>

The attribute field or fields that will be used to calculate frequency statistics.

Field
{summary_fields; summary_fields...}

The attribute field or fields that will be used to summarize the frequency results.

Field
Data types for geoprocessing tool parameters


Command line example

'  Purpose:  Determine the total amount of sales for each 
'  different customer type within each ZIP Code. 
'
'  Customer data includes customer name and address, 
'  the type of customer(restaurant, store, service station) 
'  and  the amount of sales for each customer.
' 
'  The following sample output shows the summarizing of values 
'  for each unique attribute value:
'  FREQUENCY	TYPE	ZIP	SALES
'	3	Cafe	30308	144438.80
'	3	Cafe	30309	192024.17
'	2	Theater	30308	110825.41
'	1	Theater	30312	30117.69
'	1	Theater	30318	55799.80
'
workspace E:\arcgis\ArcTutor\Geocoding\Atlanta\Atlanta.mdb
Frequency customers customers_freq type;zip SALES

Scripting syntax
About getting started with writing geoprocessing scripts
Frequency_analysis (in_table, out_table, frequency_fields, summary_fields)

Parameter Explanation Data Type
in_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
out_table (Required)

The table that will store the calculated frequency statistics.

Table
frequency_fields (Required)

The attribute field or fields that will be used to calculate frequency statistics.

Field
summary_fields (Optional)

The attribute field or fields that will be used to summarize the frequency results.

Field

Data types for geoprocessing tool parameters


Script example

# Purpose: Break all multipart features into singlepart features, 
#  and generate a report of which features were separated.

# Create the geoprocessor
import arcgisscripting
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
try:
    # 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():
        gp.AddField(inFeatureClass, "tmpUID","double")

    # 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
    gp.MultipartToSinglepart(inFeatureClass,outFeatureClass)

    # 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"
    else:
        # 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()
        while row:
            print int(row.tmpUID)
            row = rows.next()

except:
    # If an error occurred, print out the error message
    print "Error occurred"
    print gp.GetMessages()

Please visit the Feedback page to comment or give suggestions on ArcGIS Desktop Help.
Copyright © Environmental Systems Research Institute, Inc.