ArcGIS Developer

ArcGIS API for Python

Working with Multispectral Data


We can use multispectral imagery to train any arcgis.learn model that works with imagery. Apart from the standard workflow to train a arcgis.learn model there are a few additional parameters that can be used while working with multispectral imagery. In this guide we would discuss these additional parameters.


  • To work with multispectral data gdal needs to be installed in addition to fastai and pytorch, please refer to the section "Install deep learning dependencies of arcgis.learn module" on this page for detailed documentation on installation of these dependencies.


In [1]:
import arcgis
from arcgis.learn import prepare_data, UnetClassifier

Data preparation

While working with multispectral data we can use the following keyword arguments in addition to the standard parameters for the prepare_data() function.

  • Right now multispectral workflow is used for the dataset in the following mutually exclusive cases:

    • If the imagery source is not having exactly three bands
    • If there is any band other than RGB in the imagery source
    • Incase of three band iamgery all bands in the imagery source are having well known names.
    • Any of these keyword arguments is sepcified imagery_type, bands, rgb_bands.
  • imagery_type: The type of imagery used to export the training data. We can use any of the well know imagery types:

    • 'sentinel2'
    • 'naip'
    • 'landsat8'
    • 'ms' - any other type of imagery

    If the imagery used to export the training data is not one of the well know types, you can specify 'ms' against imagery_type. In that case we need to either specify rgb_bands or bands parameter to preserve weights for the RGB bands otherwise all the bands would be considered unknown.

  • bands: If training data is not exported using one of the well known imagery type, we can specify the bands contained in our imagery. For example, ['r', 'g', 'b', 'nir', 'u'] here 'nir' is and 'u' is a miscellaneous band.
  • rgb_bands: We can specify the indices of red, green, blue bands in the imagery or None if that band does not exist in the imagery. This is further used as the default band combination for visualization using the {data}.show_batch() and {model}.show_results() methods, this is an optional parameter. For example, [2, 1, 0] or [2, 1, None].
  • extract_bands: By default the model gets trained on all bands available in the imagery of our training data. We can use this parameter to filter the bands on which we want to train our model on. For example '[4, 2, 1, 0]' if we do not want to train on the band at 3 index of the imagery.
  • norm_pct: The percentage of training data used to calculate imagery statistics which is further used to normalize the data while training the model. It is an optional parameter and by default it is set to 0.3 or 30% of data.
In [2]:
data = prepare_data(

Visualize Training data

we can use the {data}.show_batch() method to visualize a few samples of the training data. Following parameters can be used with multispectral imagery to control the visualization.

  • rgb_bands: The band combination in which we want to visualize our training data, For example [2, 1, 0] or ['nir', 'green', 'blue'].
  • stretch_type: The type of stretching we want to apply to imagery in our training data for visualization.
    • 'minmax' - Default! This stretches each image chips by min-max values.
    • 'percentclip' - This stretched image chips by clipping histogram by .25%.
  • statistics_type: The type of stretching we want to apply to imagery in our training data for visualization.
    • 'dataset' - Default! This stretches each image chip using global statistics.
    • 'DRA' - stands for Dynamic Range Adjustment. This stretches each image chip using its individual statistics.
In [3]:
data.show_batch(statistics_type='DRA', alpha=0.5)

Different Band Combination

False Color Composite
red -> nir
green -> green
blue -> blue

In [4]:
data.show_batch(rgb_bands=[7, 2, 1], statistics_type='DRA', alpha=0.5)