标注 | 说明 | 数据类型 |
输入表 | 包含用于计算频率统计数据的字段的表。 | Table View; Raster Layer |
输出表 | 输出表用于存储频数统计数据。 | Table |
频数字段 | 该字段用于计算频数统计数据。 字段值的每种唯一组合都将作为新的一行包括在输出表中。 | Field |
汇总字段 (可选) | 该属性字段用于求和或添加到输出表。 值将根据频数字段的各种唯一组合进行求和。 空值将被排除在此计算之外。 | Field |
摘要
读取一个表和一组字段并创建一个包含唯一字段值和每个唯一字段值出现次数的新表。
使用情况
输出表将包含字段 Frequency 以及输入所指定的频数字段和汇总字段。
输出表将包含指定频数字段各种唯一组合的频数。
如果指定了汇总字段,则将按照每个汇总字段的数值属性值汇总频率计算的唯一属性值。
使用图层时,仅使用当前所选要素进行计算。
参数
arcpy.analysis.Frequency(in_table, out_table, frequency_fields, {summary_fields})
名称 | 说明 | 数据类型 |
in_table | 包含用于计算频率统计数据的字段的表。 | Table View; Raster Layer |
out_table | 输出表用于存储频数统计数据。 | Table |
frequency_fields [frequency_fields,...] | 该字段用于计算频数统计数据。 字段值的每种唯一组合都将作为新的一行包括在输出表中。 | Field |
summary_fields [summary_fields,...] (可选) | 该属性字段用于求和或添加到输出表。 值将根据频数字段的各种唯一组合进行求和。 空值将被排除在此计算之外。 | Field |
代码示例
以下 Python 窗口脚本演示了如何在即时模式下使用 Frequency 函数。
import arcpy
arcpy.env.workspace = "C:/data/Portland.gdb/Taxlots"
arcpy.analysis.Frequency("taxlots",
"C:/output/output.gdb/tax_frequency",
["YEARBUILT", "COUNTY"],
["LANDVAL", "BLDGVAL", "TOTALVAL"])
以下独立脚本演示了如何使用 Frequency 函数。
# Description: Run Frequency on a table
# Import system modules
import arcpy
# Set environment settings
arcpy.env.workspace = "C:/data/Portland.gdb/Taxlots"
# Set local variables
inTable = "taxlots"
outTable = "C:/output/output.gdb/tax_frequency"
frequencyFields = ["YEARBUILT", "COUNTY"]
summaryFields = ["LANDVAL", "BLDGVAL", "TOTALVAL"]
# Execute Frequency
arcpy.analysis.Frequency(inTable, outTable, frequencyFields, summaryFields)
以下独立脚本演示了如何使用多个地理处理脚本函数(包括 Frequency 函数)。
# Description: Break all multipart features into single part features,
# and generate a report of which features were separated.
# Import system modules
import arcpy
# Create variables for the input and output feature classes
inFeatureClass = "c:/data/gdb.gdb/vegetation"
outFeatureClass = "c:/data/gdb.gdb/vegetation_singlepart"
try:
# Create list of all fields in inFeatureClass
fieldNameList = [field.name for field in arcpy.ListFields(inFeatureClass)]
# Add a field to the input this will be used as a unique identifier
arcpy.management.AddField(inFeatureClass, "tmpUID", "double")
# Determine what the name of the Object ID is
OIDFieldName = arcpy.Describe(inFeatureClass).OIDFieldName
# Calculate the tmpUID to the OID
arcpy.management.CalculateField(inFeatureClass, "tmpUID",
"[" + OIDFieldName + "]")
# Run the tool to create a new fc with only singlepart features
arcpy.management.MultipartToSinglepart(inFeatureClass, outFeatureClass)
# Check if there is a different number of features in the output
# than there was in the input
inCount = int(arcpy.management.GetCount(inFeatureClass)[0])
outCount = int(arcpy.management.GetCount(outFeatureClass)[0])
if inCount != outCount:
# If there is a difference, print out the FID of the input
# features which were multipart
arcpy.analysis.Frequency(outFeatureClass,
outFeatureClass + "_freq", "tmpUID")
# Use a search cursor to go through the table, and print the tmpUID
print("Multipart features from {0}".format(inFeatureClass))
for row in arcpy.da.SearchCursor(outFeatureClass + "_freq",
["tmpUID"], "FREQUENCY > 1"):
print(int(row[0]))
else:
print("No multipart features were found")
except arcpy.ExecuteError:
print(arcpy.GetMessages())
except Exception as err:
print(err)
许可信息
- Basic: 是
- Standard: 是
- Advanced: 是