方法

フィールド演算を使用してラインの方向の計算をバッチ処理

Last Published: April 24, 2024

サマリー

The direction of multiple line features can be calculated from their start and end point coordinates by using the Field Calculator.

手順

The instructions provided describe how to calculate the line direction of multiple features using a batch process. 

  1. In the attribute table of the line features, add four new fields: START_X, START_Y, END_X, and END_Y. Set the field type for these fields to Double. 
  2. Use the Calculate Geometry function to calculate the X and Y coordinates of the line's start and end position into the four new fields. 
  3. Add another new field to the attribute table and name this field NorthAzimu. Set the field type to Double. 
  4. Calculate the NorthAzimu field with the following Python expression. Refer to the code and image below.
90-math.degrees(math.atan2(( !END_Y! - !START_Y! ),( !END_X! - !START_X! )))
formula shown in the field calculator
  1. To convert from North Azimuth to Quadrant Bearing, add another new field: Quadrant; set the data type to String.
  2. Calculate the Quadrant field by using the Python code block, as seen below. Refer to the image and ensure each item is highlighted appropriately in the Field Calculator window before running the code.
def quadrant(NorthAzimuth):
    if ((NorthAzimuth>=0) & (NorthAzimuth<90)):
        quad = "N "+str(NorthAzimuth)+" E"
    elif ((NorthAzimuth>=90) & (NorthAzimuth<180)):
        quad = "S "+str(180-NorthAzimuth)+" E"
    elif ((NorthAzimuth>=180) & (NorthAzimuth<270)):
        quad = "S "+str(NorthAzimuth-180)+" W"
    else:
        quad = "N "+str(360-NorthAzimuth)+" W"
    return quad
formula shown in the field calculator

記事 ID: 000015375

新しい問題や一般的な問題に対する通知とソリューションの受け取り

新しい AI チャットボットから、要約された回答とビデオソリューションを入手してください。

Esri Support アプリのダウンロード

関連情報

このトピックについてさらに調べる

ArcGIS エキスパートのサポートを受ける

テクニカル サポートへのお問い合わせ

Esri Support アプリのダウンロード

ダウンロード オプションに移動