Calculate Metrics (Topographic Production)

Summary

Populates metrics for features in a geodatabase. Metrics include length, width, area, and elevation attributes.

Usage

  • Supported feature attribute metrics include the following:

    • Angle of Orientation—The default attributes are AOO, DOF, and FEO.
    • Area—The default attributes are ARA, ARE, and ARE_.
    • Elevation—The default attributes are ZV2 and ZVH (must be z-enabled data).
    • Length—The default attributes are LEG, LEN, LEN_, LGN, and LZN.
    • Width—The default attributes are WID, WID_, and WGP.

  • Input metric types are processed based on the geometry of the feature class:

    • Points—Elevation
    • Lines—Length and Elevation
    • Polygons—Length, Width, Area, Angle of Orientation, and Elevation

  • The Input Length Attributes, Input Width Attributes, Input Area Attributes, Input Angle of Orientation Attributes, and Input Elevation Attributes parameters reference a comma-delimited list of field names in your data model. If one or more fields exist in Input Features, the field will be calculated according to the metrics chosen in the Input Metric Types parameter.

  • You can add your own field names to the list of options in the Input Length Attributes, Input Width Attributes, Input Area Attributes, Input Angle of Orientation Attributes, and Input Elevation Attributes parameters. This tool will attempt to compute metrics in your custom field.

Parameters

LabelExplanationData Type
Input Features

The features on which metrics will be calculated.

Feature Layer
Input Metric Types

Specifies the types of metrics to calculate, including angle of orientation, area, elevation, length, and width.

  • Angle of orientation —Calculate angle of orientation metrics
  • Area —Calculate area metrics
  • Elevation —Calculate elevation metrics
  • Length —Calculate length metrics
  • Width —Calculate width metrics
String
Input Length Attributes
(Optional)

A comma-delimited string of field names from which the length metrics will be calculated. The default is LEG,LEN,LEN_,LGN,LZN. You can add the names of other length metric fields; if the fields exist in Input Features, they will be computed.

String
Input Width Attributes
(Optional)

A comma-delimited string of field names from which the width metrics will be calculated. The default is WID,WID_,WGP. You can add the names of other width metric fields; if the fields exist in Input Features, they will be computed.

String
Input Area Attributes
(Optional)

A comma-delimited string of field names from which the area metrics will be calculated. The default is ARA,ARE,ARE_. You can add the names of other area metric fields; if the fields exist in Input Features, they will be computed.

String
Input Angle of Orientation Attributes
(Optional)

A comma-delimited string of field names from which the angle of orientation metrics will be calculated. The default is AOO,DOF,FEO. You can add the names of other angle of orientation metric fields; if the fields exist in Input Features, they will be computed.

String
Input Elevation Attributes
(Optional)

A comma-delimited string of field names from which the elevation metrics will be calculated. The default is ZV2,ZVH. You can add the names of other elevation metric fields; if the fields exist in Input Features, they will be computed.

String
Input Floating Point Precision
(Optional)

The precision of the metrics written to the target attributes.

Long

Derived Output

LabelExplanationData Type
Output Features

The features on which metrics were calculated.

Feature Layer

arcpy.topographic.CalculateMetrics(in_features, in_metric_types, {in_length_attributes}, {in_width_attributes}, {in_area_attributes}, {in_angle_attributes}, {in_elevation_attributes}, {in_precision})
NameExplanationData Type
in_features
[in_features,...]

The features on which metrics will be calculated.

Feature Layer
in_metric_types
[in_metric_types,...]

Specifies the types of metrics to calculate, including angle of orientation, area, elevation, length, and width.

  • ANGLE_OF_ORIENTATIONCalculate angle of orientation metrics
  • AREACalculate area metrics
  • ELEVATIONCalculate elevation metrics
  • LENGTHCalculate length metrics
  • WIDTHCalculate width metrics
String
in_length_attributes
(Optional)

A comma-delimited string of field names from which the length metrics will be calculated. The default is LEG,LEN,LEN_,LGN,LZN. You can add the names of other length metric fields; if the fields exist in Input Features, they will be computed.

String
in_width_attributes
(Optional)

A comma-delimited string of field names from which the width metrics will be calculated. The default is WID,WID_,WGP. You can add the names of other width metric fields; if the fields exist in Input Features, they will be computed.

String
in_area_attributes
(Optional)

A comma-delimited string of field names from which the area metrics will be calculated. The default is ARA,ARE,ARE_. You can add the names of other area metric fields; if the fields exist in Input Features, they will be computed.

String
in_angle_attributes
(Optional)

A comma-delimited string of field names from which the angle of orientation metrics will be calculated. The default is AOO,DOF,FEO. You can add the names of other angle of orientation metric fields; if the fields exist in Input Features, they will be computed.

String
in_elevation_attributes
(Optional)

A comma-delimited string of field names from which the elevation metrics will be calculated. The default is ZV2,ZVH. You can add the names of other elevation metric fields; if the fields exist in Input Features, they will be computed.

String
in_precision
(Optional)

The precision of the metrics written to the target attributes.

Long

Derived Output

NameExplanationData Type
out_features

The features on which metrics were calculated.

Feature Layer

Code sample

CalculateMetrics example 1 (stand-alone script)

The following code sample calculates the width fields for polyline features in the attribute table.

# Name: CalculateMetrics_sample1.py
# Description: Calculating the width field for features in a polyline feature class

# Import System Modules
import arcpy

# Check Out Extensions
arcpy.CheckOutExtension('Foundation')

# Setting Local Variables
input_features = r'C:\Temp\Test.gdb\RiverLines'
field_name = 'WID'

# Creating feature layer
river_lines = arcpy.management.MakeFeatureLayer(input_features, 'RiverLines').getOutput(0)

# Calculating WIDTH of input features on the WID field
arcpy.topographic.CalculateMetrics(river_lines, "WIDTH", "#", field_name, "#", "#", "#", "#")

# Check In Extensions
arcpy.CheckInExtension('Foundation')
CalculateMetrics example 2 (stand-alone script)

The following code sample iterates through the features in a database and calculates metric attributes.

# Name: CalculateMetrics_sample2.py
# Description: Iterates through the features in a database and calculates metric attributes

# Import System Modules
import arcpy
import string
import os

# Check Out Extensions
arcpy.CheckOutExtension('Foundation')

# Setting Local Variables
input_database = r'C:\Data\Sample.gdb'
metric_type = 'LENGTH;WIDTH;AREA;ANGLE_OF_ORIENTATION;ELEVATION'

# Getting feature classes from database
arcpy.env.workspace = input_database
feature_classes = []
feature_datasets = arcpy.ListDatasets('*', 'Feature')
for dataset in feature_datasets:
    fclass = arcpy.ListFeatureClasses('*', '', dataset)
    for fc in fclass:
        feature_classes.append(os.path.join(input_database, dataset, fc))

# Converting feature classes into layers
layer_list = []
for feat_class in feature_classes:
    class_name = string.split(os.path.split(feat_class)[1], '.')[-1]
    arcpy.management.MakeFeatureLayer(feat_class, class_name)
    layer_list.append(class_name)

# Creating string for input to Calculate Metrics Fields tool
feature_string = ''
for layer in layer_list:
    feature_string += '{};'.format(layer)


# Calculating Metric fields on all features classes in the in[ut database
arcpy.topographic.CalculateMetrics(feature_string, metric_type, '#', '#', '#', '#', '#', '#')

# Check In Extensions
arcpy.CheckInExtension('Foundation')

Environments

Licensing information

  • Basic: No
  • Standard: Requires Production Mapping
  • Advanced: Requires Production Mapping

Related topics