ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • Aide
  • Sign Out
ArcGIS Desktop

ArcGIS Online

La plateforme cartographique de votre organisation

ArcGIS Desktop

Un SIG professionnel complet

ArcGIS Enterprise

SIG dans votre entreprise

ArcGIS Developers

Outils de création d'applications de localisation

ArcGIS Solutions

Modèles d'applications et de cartes gratuits pour votre secteur d'activité

ArcGIS Marketplace

Téléchargez des applications et des données pour votre organisation.

  • Documentation
  • Support
Esri
  • Se connecter
user
  • Mon profil
  • Déconnexion

ArcMap

  • Accueil
  • Commencer
  • Carte
  • Analyser
  • Gérer les données
  • Outils
  • Extensions

Calculate Metrics

  • Résumé
  • Utilisation
  • Syntaxe
  • Exemple de code
  • Environnements
  • Informations de licence

Résumé

Populates metrics for features in ArcGIS Defense Mapping data models. Metrics include length, width, area, and elevation attributes.

Utilisation

  • Certain attributes must be present in Input Features. Attributes pertain to Defense Mapping data models, including Multinational Geospatial Co-production Program (MGCP) and Vector Map Level 1 (VMap 1) and Vector Map Level 2 (VMap 2).

  • Supported attributes include the following:

    • Angle of Orientation—AOO, DOF, and FEO
    • Area—ARA, ARE, and ARE_
    • Elevation—ZV2 and ZVH (must be z-enabled data)
    • Length—LEG, LEN, LEN_, LGN, and LZN
    • Width—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.

Syntaxe

arcpy.defense.CalculateMetrics(in_features, in_metric_types, {in_length_attributes}, {in_width_attributes}, {in_area_attributes}, {in_angle_attributes}, {in_elevation_attributes}, {in_precision})
ParamètreExplicationType de données
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_ORIENTATION —Calculate angle of orientation metrics
  • AREA —Calculate area metrics
  • ELEVATION —Calculate elevation metrics
  • LENGTH —Calculate length metrics
  • WIDTH —Calculate width metrics
String
in_length_attributes
(Facultatif)

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
(Facultatif)

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
(Facultatif)

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
(Facultatif)

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
(Facultatif)

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
(Facultatif)

The precision of the metrics written to the target attributes.

Long

Sortie dérivée

NomExplicationType de données
out_features

The features on which metrics were calculated.

Feature Layer

Exemple de code

CalculateMetrics example 1 (stand-alone script)

The following code sample calculates the width for the WatrcrsL features and populates the WID attribute in the attribute table.

# Importing necessary modules
from arcpy import management, defense

# Creating feature layers
management.MakeFeatureLayer(r'C:\Sample\Data.gdb\MGCP\BuildA', 'WatrcrsL')

# Calculating WIDTH attribute and taking all defaults
defense.CalculateMetrics('WatrcrsL', "WIDTH", "#", "#", "#", "#", "#", "#")
CalculateMetrics example 2 (stand-alone script)

The following code example demonstrates how to execute the CalculateMetrics tool.

# Running Calculate Metrics on all feature calsses in a database taking the defaults for optional parameters
# Importing arcpy, string, and os modules
import arcpy, string, os

# Checking out Defense extension
arcpy.CheckOutExtension('defense')

# Setting input database
input_database = r'C:\Data\TDS_6_1.gdb'

# 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 Representation Fields tool
feature_string = ''
for layer in layer_list:
    feature_string += '{};'.format(layer)

# Setting variables for parameters
input_features = r'C:\Data\TDS_6_1.gdb\TDS\TransportationGroundSrf;C:\Data\TDS_6_1.gdb\TDS\StructureSrf'
metric_type = 'LENGTH;WIDTH;AREA;ANGLE_OF_ORIENTATION;ELEVATION'

# Calling Calculate Metrics tool
arcpy.defense.CalculateMetrics(feature_string, metric_type, '#', '#', '#', '#', '#', '#')

# Checking in Defense extension
arcpy.CheckInExtension('defense')

Environnements

  • Espace de travail courant

Informations de licence

  • Basic: Non
  • Standard: Requiert Defense Mapping
  • Advanced: Requiert Defense Mapping

Rubriques connexes

  • An overview of the Features toolset

ArcGIS Desktop

  • Accueil
  • Documentation
  • Support

ArcGIS

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS
  • ArcGIS Developer
  • ArcGIS Solutions
  • ArcGIS Marketplace

A propos d'Esri

  • A propos de la société
  • Carrières
  • Blog d’Esri
  • Conférence des utilisateurs
  • Sommet des développeurs
Esri
Donnez-nous votre avis.
Copyright © 2021 Esri. | Confidentialité | Légal