Skip To Content

Custom raster type implementation in Python

Raster types can be customized and implemented in Python according to the type of raster data you want to add. Raster types can be compared to a set of functions that recognize the format of the metadata structure associated with your data. The raster type can also parse the metadata to retrieve information such as paths to the data files, spatial reference information, and metadata (sensor name, sun elevation, sun azimuth, sun distance, acquisition date, radiance, and reflectance parameters).

In addition to parsing and reading metadata information from the metadata file, a raster type also defines the processing templates that are applicable to the type of data being read. The processing templates can combine different pieces of information from the source data to generate an output that is more meaningful and convenient for display and further analysis. Most of the raster types based on sensor data define Multispectral as one of its processing templates. Many other templates can be defined based on the type of data available for a product. For example, the Landsat 8 raster type defines various templates such as Multispectral, Panchromatic, Pansharpened, Vegetation, Cirrus, and Snow/Ice.

To learn more about ArcGIS Raster Types implemented in Python, see Github Raster Types.

Properties of a raster type

A raster type is created by defining one or more of the following properties from its source data:

  • Band properties—Such as band name, minimum and maximum wavelength, and solar irradiance
  • Processing templates—Raster function templates containing inputs, functions, and values or variables
  • Auxiliary fields—Which are added to a mosaic dataset
  • Auxiliary inputs—Additional information required by the raster type to fully describe the data source, such as a DEM that should be applied on the source dataset to orthorectify the image

Custom raster type implementation

The details of implementing a raster type in a Python module are described below. A raster type is a layer that facilitates the interaction with the application on various aspects of the data. Raster types are also core to adding rasters to a mosaic dataset using the Add Rasters To Mosaic Dataset tool.

The ArcGIS framework identifies raster types by using the well-known factory pattern. A raster type factory holds a collection of raster types, where the collection can be organized based on specific criteria, or it can just be a container that holds all raster types.

There are three components of a raster type that are implemented in Python:

How does it work?

The architecture of implementing a raster type in Python is an intuitive process. ArcGIS provides a raster type adapter that interfaces with the ArcGIS system and the Python module for the raster type implementation. The adapter loads the Python module and looks for RasterTypeFactory to identify the participating raster types within this module. The RasterTypeFactory must contain at least one public function, getRasterTypesInfo, which returns information about all the raster types within the factory. The getRasterTypesInfo function returns a dictionary of RasterTypeDefinitions. The adapter then retrieves information about the RasterTypes and treats the Python-based raster types in the same way as any other raster types that are contained in ArcGIS. The ArcGIS framework then interacts with the Python-based raster type using the Builder API and the Crawler API.

Once you have implemented your raster type using Python, place the Python module in the [InstallDirectory]\Resources\Raster\Types folder.

The raster type framework in ArcGIS will pick up all the *.py files from this location and check whether they contain valid raster types. If valid raster types are found, they will be added to the list of supported raster types in the Add Rasters to Mosaic Dataset tool.

To learn more on how to implement a raster type in a Python module, see Anatomy of Python Raster Type.

Related topics