Oriented imagery custom input types

Oriented imagery custom input types can be implemented in Python according to the input image data you want to add to the oriented imagery dataset. The custom input types allow users to integrate images to oriented imagery dataset while maintaining consistency and adhering to predefined metadata standards.

Use the guidelines below when creating the Python module. The module provides functionality to define the metadata, retrieve values, and extract data in the oriented imagery schema.

Module and class naming conventions

Name the folder containing the module, the module, and the class after the input type for adding images to the oriented imagery dataset. The naming convention ensures that the module and the class are identifiable and intuitive to use.

For example, if the input type is MyInputType, name the folder, module, and class as follows:

  • Folder name—MyInputType
  • Module name—MyInputType.py
  • Class name—MyInputType

Class methods

The class includes methods for defining input data schema, auxiliary parameters, oriented imagery dataset fields, and oriented imagery dataset properties, and generating oriented imagery records. The class must contain the input_data_schema, auxiliary_parameters, oriented_imagery_fields, oriented_imagery_properties, and oriented_imagery_records methods.

input_data_schema

The input_data_schema method defines the required input data to generate oriented imagery records and returns the value described below.

Return

The input_data_schema method returns a dictionary containing the input data schema.

Each key represents the input required for adding the images to the oriented imagery dataset, and it must be specified in the key's value whether it is required or an optional input.

This is an example of the input_data_schema method.

def input_data_schema(self):
    """Defines input data."""
    return {
        "Metadata File": {"required": True},
        "Image Location": {"required": True},
        "DEM": {"required": False}					
    }

auxiliary_parameters

The auxiliary_parameters method defines auxiliary parameters with the default values.

Return

The auxiliary_parameters method returns a dictionary containing auxiliary parameters information.

The auxiliary parameter must be specified as the key, and the key's corresponding default value as strings. If no auxiliary parameter is required, an empty dictionary must be returned.

This is an example of the auxiliary_parameters method.

def auxiliary_parameters(self):
    """Defines auxiliary parameters."""
    return {
        "Default Ground Elevation": "0",
        "Offset": "1.2"		
    }

In the Geoprocessing pane, the Add Images From Custom Input Type tool's Input Data and Auxiliary Parameters parameters update based on the return values of the input_data_schema and auxiliary_parameters methods.

oriented_imagery_fields

The oriented_imagery_fields method defines the fields that must be added to the oriented imagery dataset.

Arguments

The arguments are as follows:

  • input_data—A dictionary containing input data information.

    The keys of input_data correspond to the keys returned by the input_data_schema method, and the values are the input data provided by the user as strings.

    This is an example of an input_data value.

    {
         "Metadata File": "C:/Documents/Files/metadata.json",
         "Image Location": "C:/Documents/Images",
         "DEM": None					
     }

  • aux_input—A dictionary of auxiliary parameters and values.

    The keys of aux_input correspond to the keys returned by the auxiliary_parameters method, and the values are the parameter values as strings.

    This is an example of an aux_input value.

    {
         "Default Ground Elevation": "309",
         "Offset": "1.2"				
     }

Return

The oriented_imagery_fields method returns a tuple with the following lists:

This is an example of the oriented_imagery_fields method.

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

The oriented_imagery_fields method defines the default values for the oriented imagery dataset properties. These values can be changed using the Update Oriented Imagery Dataset Properties tool.

Arguments

The arguments are as follows:

  • input_data—A dictionary containing input data information.

    The keys of input_data correspond to the keys returned by the input_data_schema method, and the values are the input data provided by the user as strings.

  • aux_input—A dictionary of auxiliary parameters and values.

    The keys of the aux_input correspond to the keys returned by the auxiliary_parameters method, and the values are the parameter values in string format.

Return

The oriented_imagery_fields method returns a dictionary with the oriented imagery dataset property names and values.

The ArcPy Describe function retrieves all the oriented imagery properties and their corresponding values as a dictionary. The oriented_imagery_properties method can return any property except horizontalMeasurementUnit. The horizontal measurement unit is defined by the dataset's coordinate system.

This is an example of the oriented_imagery_properties method.

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

The oriented_imagery_records method reads the metadata to retrieve the information and yields dictionaries with values in the defined schema.

Arguments

The arguments are as follows:

  • input_data—A dictionary containing input data information.

    The keys of input_data correspond to the keys returned by the input_data_schema method, and the values are the input data provided by the user in string format.

  • aux_input—A dictionary of auxiliary parameters and values.

    The keys of the aux_input correspond to the keys returned by the auxiliary_parameters method, and the values are the parameter values as strings.

Yield

The oriented_imagery_records method yields a dictionary containing the oriented imagery dataset table field values.

The dictionary must contain all the fields that are defined in the oriented_imagery_fields method as its keys. The SHAPE@ key must contain the camera location as an ArcPy PointGeometry object.

This is an example of the oriented_imagery_properties method.

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
    }

Related topics