方向付き画像のカスタム入力タイプは、方向付き画像データセットに追加する入力画像データに応じて、Python に実装できます。 ユーザーはカスタム入力タイプを使用することで、一貫性を保ち、事前に定義されたメタデータ基準を順守しつつ、方向付き画像データセットに画像を統合できます。
Python モジュールを作成する際は、以下のガイドラインを使用します。 このモジュールは、メタデータの定義、値の取得、方向付き画像スキーマのデータの抽出を行う機能を提供します。
モジュールおよびクラスの命名規則
方向付き画像データセットに画像を追加するための入力タイプにちなみ、モジュールを含むフォルダー、モジュール、クラスに名前を付けます。 命名規則に従うことでモジュールとクラスを識別しやすくなり、直感的に使用できるようになります。
たとえば、入力タイプが MyInputType の場合、フォルダー、モジュール、クラスを次のように名付けます。
- フォルダー名 - MyInputType
- モジュール名 - MyInputType.py
- クラス名 - MyInputType
クラス メソッド
クラスには、入力データ スキーマ、補助パラメーター、方向付き画像データセット フィールド、方向付き画像データセットのプロパティを定義し、方向付き画像レコードを生成するためのメソッドが含まれています。 クラスには input_data_schema、auxiliary_parameters、oriented_imagery_fields、oriented_imagery_properties、oriented_imagery_records メソッドが含まれている必要があります。
input_data_schema
input_data_schema メソッドは、方向付き画像レコードを生成するために必要な入力データを定義し、以下に説明する値を返します。
戻る
input_data_schema メソッドは、入力データ スキーマを含むディクショナリを返します。
各キーは、方向付き画像データセットに画像を追加するために必要な入力を表し、必須の入力であるか任意の入力であるかをキーの値で指定する必要があります。
これは input_data_schema メソッドの例です。def input_data_schema(self):
    """Defines input data."""
    return {
        "Metadata File": {"required": True},
        "Image Location": {"required": True},
        "DEM": {"required": False}					
    }
auxiliary_parameters
auxiliary_parameters メソッドはデフォルト値を持つ補助パラメーターを定義します。
戻る
auxiliary_parameters メソッドは補助パラメーター情報を含むディクショナリを返します。
補助パラメーターはキーとして指定し、キーに対応するデフォルト値は文字列として指定する必要があります。 補助パラメーターが必須ではない場合、空白のディクショナリを返す必要があります。
これは auxiliary_parameters メソッドの例です。def auxiliary_parameters(self):
    """Defines auxiliary parameters."""
    return {
        "Default Ground Elevation": "0",
        "Offset": "1.2"		
    }
[ジオプロセシング] ウィンドウの [カスタム入力タイプからの画像の追加 (Add Images From Custom Input Type)] ツールの [入力データ] パラメーターと [補助パラメーター] パラメーターは input_data_schema メソッドと auxiliary_parameters メソッドの戻り値に基づいて更新されます。
oriented_imagery_fields
oriented_imagery_fields メソッドは、方向付き画像データセットに追加する必要があるフィールドを定義します。
引数
引数は次のとおりです。
- input_data - 入力データ情報を含むディクショナリ。input_data のキーは input_data_schema メソッドによって返されるキーに対応し、値はユーザーが文字列として提供した入力データです。 これは input_data 値の例です。 { "Metadata File": "C:/Documents/Files/metadata.json", "Image Location": "C:/Documents/Images", "DEM": None }
- aux_input - 補助パラメーターと値のディクショナリ。aux_input のキーは auxiliary_parameters メソッドによって返されるキーに対応し、値は文字列としてのパラメーター値です。 これは aux_input 値の例です。 { "Default Ground Elevation": "309", "Offset": "1.2" }
戻る
oriented_imagery_fields メソッドは、以下のリストを含むタプルを返します。
- 文字列のリスト - 方向付き画像属性テーブル スキーマの一部であるフィールド。 ImagePath フィールドと SHAPE@ フィールドは必須で、リストに存在する必要があります。
- ディクショナリのリスト - 追加のカスタム フィールドは、field_name と field_type をキーとするディクショナリのリストとして提供する必要があります。 追加のフィールド名が定義されている場合は、ファイル名のルールと制限事項、およびサポートされている ArcGIS フィールド データ タイプを確認します。
これは oriented_imagery_fields メソッドの例です。def oriented_imagery_fields(self, input_data, aux_params):
    """Define the input schema for the tool."""
    standard_fields = [
        "SHAPE@",
        "Name",
        "ImagePath",
        "AcquisitionDate",
        "CameraHeading",
        "CameraPitch",
        "CameraRoll",
        "HorizontalFieldOfView",
        "VerticalFieldOfView",
        "CameraHeight",
        "FarDistance",
        "NearDistance",
        "OrientedImageryType",
        "CameraOrientation"
    ]
    additional_fields = [
        {"field_name":"CameraId", "field_type":"LONG"},
        {"field_name":"CameraType", "field_type":"TEXT"}
    ]
    return standard_fields, additional_fields
oriented_imagery_properties
oriented_imagery_fields メソッドは、方向付き画像データセット プロパティのデフォルト値を定義します。 これらの値は、[方向付き画像データセット プロパティの更新 (Update Oriented Imagery Dataset Properties)] ツールを使用して変更できます。
引数
引数は次のとおりです。
- input_data - 入力データ情報を含むディクショナリ。input_data のキーは input_data_schema メソッドによって返されるキーに対応し、値はユーザーが文字列として提供した入力データです。 
- aux_input - 補助パラメーターと値のディクショナリ。aux_input のキーは auxiliary_parameters メソッドによって返されるキーに対応し、値は文字列形式のパラメーター値です。 
戻る
oriented_imagery_fields メソッドは、方向付き画像データセット プロパティの名前と値を含むディクショナリを返します。
ArcPy Describe 関数はすべての方向付き画像プロパティと対応する値をディクショナリとして取得します。 oriented_imagery_properties メソッドは horizontalMeasurementUnit 以外の任意のプロパティを返すことができます。 水平方向の計測単位はデータセットの座標系によって定義されます。
これは oriented_imagery_properties メソッドの例です。def oriented_imagery_properties(self, input_data, aux_params):
    """Define the default properties for the tool."""
    return {
        "maximumDistance": 2000,
        "orientedImageryType": "Oblique",
        "cameraPitch": 45,
        "farDistance": 500,
        "nearDistance": 120
    }
oriented_imagery_records
oriented_imagery_records メソッドはメタデータを読み込んで情報を取得し、定義されたスキーマの値を持つディクショナリを生成します。
引数
引数は次のとおりです。
- input_data - 入力データ情報を含むディクショナリ。input_data のキーは input_data_schema メソッドによって返されるキーに対応し、値はユーザーが文字列形式で提供した入力データです。 
- aux_input - 補助パラメーターと値のディクショナリ。aux_input のキーは auxiliary_parameters メソッドによって返されるキーに対応し、値は文字列としてのパラメーター値です。 
徐行
oriented_imagery_records メソッドは方向付き画像データセットのテーブル フィールド値を含むディクショナリを生成します。
ディクショナリには oriented_imagery_fields メソッドで定義されているすべてのフィールドがキーとして含まれている必要があります。 SHAPE@ キーにはカメラの位置を ArcPy PointGeometry オブジェクトとして含める必要があります。
これは oriented_imagery_properties メソッドの例です。def oriented_imagery_properties(self, input_data, aux_input):
    """Generate the oriented imagery records."""
    metadata = input_data["Metadata File"]
    image_folder = input_data["Image Location"]
    dem = input_data["DEM"]
    def_ground = aux_input["Default Ground Elevation"]
    offset = aux_input["Offset"]
    # Implementation goes here
    yield {
        "SHAPE@": camera_point_geom,
        "Name": image_name,
        "ImagePath": image_path,
        "AcquisitionDate": acquisition_date,
        "CameraHeading": heading,
        "CameraPitch": pitch,
        "CameraRoll": roll,
        "HorizontalFieldOfView": hfov,
        "VerticalFieldOfView": vfov,
        "CameraHeight": camera_height,
        "FarDistance": far_distance,
        "NearDistance": near_distance,
        "OrientedImageryType": oi_type,
        "CameraOrientation": cam_ori,
        "CameraId": int(c_id),
        "CameraType": c_type
    }