FRAMES | NO FRAMES
Raster Functions

Overview

The image service's export image operation supports a renderingRule parameter. This parameter has the following JSON syntax:

{
  "rasterFunction" : "<rasterFunctionName>",
  "rasterFunctionArguments" : {<rasterFunctionArguments>},
  "variableName" : "<variableName>"
}

Image service has a few well-known raster functions that does not need to be pre-configured with service. The structure of the rasterFunctionArguments object varies based on the rasterFunction name.

Image service REST supports Aspect, Colormap, Hillshade, NDVI, ShadedRelief, Slope, Statistics, Stretch functions in 10.0.

New at 10.1, Image service REST supports Convolution, Remap, BandArithmetic, Clip, Geometric functions.

New at 10.1, client can invoke a raster function template that is pre-configured on server-side along with the service. A raster function template defines a processing chain that is composed of one or more raster functions, including customized raster functions that're extended based on ArcObjects. Information of these raster function templates are available through RasterFunctionInfos property on image service root resource page. Client may omit rasterFunctionArguments to take default configuration in raster function template, or overwrite them by specifying argument parameters (argument names and value types are defined by the author of each raster function template and are not discoverable through REST).

This document lists these well-known raster functions supported by the REST API, as well as an example of using raster function template defined by a service.

"rasterFunction" : "Aspect"

The Aspect raster function takes no arguments. Hence, specifying only the rasterFunction property suffices in this case.

{
  "rasterFunction" : "Aspect"
}

"rasterFunction" : "Colormap"

The arguments for the Colormap function are as shown below:

{
  "rasterFunction" : "Colormap",
  "rasterFunctionArguments" : {
    "ColormapName" : "<Random | NDVI | Elevation | Gray>",
    "Colormap" : [
      [<value1>, <red1>, <green1>, <blue1>], //[int, int, int, int]
      [<value2>, <red2>, <green2>, <blue2>]
    ]
  },
  "variableName" : "Raster"
}

Example 1:

{
  "rasterFunction" : "Colormap",
  "rasterFunctionArguments" : {
    "ColormapName" : "Random"
  },
  "variableName" : "Raster"
}

Example 2:

{
  "rasterFunction" : "Colormap",
  "rasterFunctionArguments" : {
    "Colormap" : [
      [0, 1, 2, 3],
      [2, 45, 52, 13]
    ]
  },
  "variableName" : "Raster"
}

"rasterFunction" : "Hillshade"

The arguments for the Hillshade function are as shown below:

{
  "rasterFunction" : "Hillshade",
  "rasterFunctionArguments" : {
    "Azimuth" : <Azimuth>, //double (e.g. 215.0)
    "Altitude" : <Altitude>, //double (e.g. 75.0)
    "ZFactor" : <ZFactor> //double (e.g. 0.3)
  },
  "variableName" : "DEM"
}

Example:

{
  "rasterFunction" : "Hillshade",
  "rasterFunctionArguments" : {
    "Azimuth" : 215.0,
    "Altitude" : 75.0,
    "ZFactor" : 0.3
  },
  "variableName" : "DEM"
}

"rasterFunction" : "NDVI"

The arguments for the NDVI function are as shown below:

{
  "rasterFunction" : "NDVI",
  "rasterFunctionArguments" : {
    "VisibleBandID" : <VisibleBandID>, //int (zero-based band id, e.g. 2)
    "InfraredBandID" : <InfraredBandID> //int (zero-based band id, e.g. 1)
  },
  "variableName" : "Raster"
}

Example:

{
  "rasterFunction" : "NDVI",
  "rasterFunctionArguments" : {
    "VisibleBandID" : 2,
    "InfraredBandID" : 1
  },
  "variableName" : "Raster"
}

"rasterFunction" : "ShadedRelief"

The arguments for the ShadedRelief function are as shown below:

{
  "rasterFunction" : "ShadedRelief",
  "rasterFunctionArguments" : {
    "Azimuth" : <Azimuth>, //double (e.g. 215.0)
    "Altitude" : <Altitude>, //double (e.g. 75.0)
    "ZFactor" : <ZFactor>, //double (e.g. 0.3)
    "Colormap" : [
      [<value1>, <red1>, <green1>, <blue1>], //[int, int, int, int]
      [<value2>, <red2>, <green2>, <blue2>]
    ]
  },
  "variableName" : "Raster"
}

Example:

{
  "rasterFunction" : "ShadedRelief",
  "rasterFunctionArguments" : {
    "Azimuth" : 215.0,
    "Altitude" : 75.0,
    "ZFactor" : 0.3,
    "Colormap" : [
      [0, 1, 2, 3],
      [2, 45, 52, 13]
    ]
  },
  "variableName" : "Raster"
}

"rasterFunction" : "Slope"

The arguments for the Slope function are as shown below:

{
  "rasterFunction" : "Slope",
  "rasterFunctionArguments" : {
    "ZFactor" : <ZFactor> //double (e.g. 0.3)
  },
  "variableName" : "DEM"
}

Example:

{
  "rasterFunction" : "Slope",
  "rasterFunctionArguments" : {
    "ZFactor" : 0.3
  },
  "variableName" : "DEM"
}

"rasterFunction" : "Statistics"

The arguments for the Statistics function are as shown below:

{
  "rasterFunction" : "Statistics",
  "rasterFunctionArguments" : {
    "Type" : "<Min | Max | Mean | StandardDeviation>",
    "KernelColumns" : <KernelColumns>, //int (e.g. 3)
    "KernelRows" : <KernelRows> //int (e.g. 3)
  },
  "variableName" : "Raster"
}

Example:

{
  "rasterFunction" : "Statistics",
  "rasterFunctionArguments" : {
    "Type" : "Mean",
    "KernelColumns" : 3,
    "KernelRows" : 3
  },
  "variableName" : "Raster"
}

"rasterFunction" : "Stretch"

The arguments for the Stretch function are as shown below:

{
  "rasterFunction" : "Stretch",
  "rasterFunctionArguments" : {
    "StretchType" : <StretchType>, //int (0 = None, 3 = StandardDeviation, 4 = Histogram Equalization, 5 = MinMax)
    "NumberOfStandardDeviations" : <NumberOfStandardDeviations>, //int (e.g. 2)
    "Statistics" : [
      [<min1>, <max1>, <mean1>, <standardDeviation1>], //[double, double, double, double]
      [<min2>, <max2>, <mean2>, <standardDeviation2>]
    ],
    "Gamma" : [<gamma1>, <gamma2>] //array of doubles
  },
  "variableName" : "Raster"
}

Example:

{
  "rasterFunction" : "Stretch",
  "rasterFunctionArguments" : {
    "StretchType" : 3,
    "NumberOfStandardDeviations" : 2,
    "Statistics" : [
      [0.2, 222.46, 99.35, 1.64],
      [5.56, 100.345, 45.4, 3.96],
      [0, 352.37, 172.284, 2]
    ],
    "Gamma" : [1.25, 2, 3.95]
  },
  "variableName" : "Raster"
}

"rasterFunction" : "Convolution"

//Added in 10.1

The arguments for the Convolution function are as shown below:

{
  "rasterFunction" : "Convolution",
  "rasterFunctionArguments" : {
    "Columns" : <Columns>,
    "Rows" : <Rows>,
    "Kernel" : [<k11>, <k12>, ... <k1n>, <k21>, <k22>, <k2n>,... <km1>, <km2>, <kmn>]//an array that has m x n elements
    "Type" : <Type>,//int (-1 = UserDefined, 0 = LineDetectionHorizontal, 1 = LineDetectionVertical, 2 = LineDetectionLeftDiagonal, 3 = LineDetectionRightDiagonal, 4 = GradientNorth, 5 = GradientWest, 6 = GradientEast, 7 = GradientSouth, 8 = GradientNorthEast, 9 = GradientNorthWest, 10 = SmoothArithmeticMean, 11 = Smoothing3x3, 12 = Smoothing5x5, 13 = Sharpening3x3, 14 = Sharpening5x5, 15 = Laplacian3x3, 16 = Laplacian5x5, 17 = SobelHorizontal, 18 = SobelVertical, 19 = Sharpen, 20 = Sharpen2, 21 = PointSpread)    
  },
  "variableName" : "Raster"
}

Example:

{
  "rasterFunction" : "Convolution",
  "rasterFunctionArguments" : {
    "Type" : 11
  },
  "variableName" : "Raster"
}

"rasterFunction" : "Remap"

//Added in 10.1

The arguments for the Remap function are as shown below:

{
  "rasterFunction" : "Remap",
  "rasterFunctionArguments" : {
    "InputRanges" : [<value1>, <value2>, <value3>],//[double, double, double]
    "OutputValues" : [<value1>, <value2>, <value3>],//[double, double, double]
    "NoDataRanges" : [<value1>, <value2>, <value3>],//[double, double, double]
    "AllowUnmatched" : <true|false>//boolean 
  },
  "variableName" : "Raster"
}

Example:

{
  "rasterFunction" : "Remap",
  "rasterFunctionArguments" : {
    "InputRanges" : [0,100,101,200],
    "OutputValues" : [5,125],
  },
  "variableName" : "Raster"
}

"rasterFunction" : "BandArithmetic"

//Added in 10.1

The arguments for the BandArithmetic function are as shown below:

{
  "rasterFunction" : "BandArithmetic",
  "rasterFunctionArguments" : {
    "Method" : <Method>,//int (0 = UserDefined, 1 = NDVI, 2 = SAVI, 3 = TSAVI, 4 = MSAVI, 5 = GEMI, 6 = PVI, 7 = GVITM, 8 = Sultan)
    "BandIndexes" : "<BandIndexes>"//string e.g. (B3 - B1 / B3 + B1)
  },
  "variableName" : "Raster"
}

Example:

{
  "rasterFunction" : "BandArithmetic",
  "rasterFunctionArguments" : {
    "Method" : 0,
    "BandIndexes" : "(B3 - B1 / B3 + B1)"
  },
  "variableName" : "Raster"
}

"rasterFunction" : "Clip"

//Added in 10.1

The arguments for the Clip function are as shown below:

{
  "rasterFunction" : "Clip",
  "rasterFunctionArguments" : {
    "ClippingGeometry" : <geometry>,//a polygon or envelope
    "ClippingType" : <clippingType>//int (1= clippingOutside, 2=clippingInside), use 1 to keep image inside of the geometry
  },
  "variableName" : "Raster"
}

Example:


{
  "rasterFunction" : "Clip",
  "rasterFunctionArguments" : {
    "ClippingGeometry" : {
      "rings" : [[[10,10], [9,11], [10,12], [11,11], [12,10],[10,10]]], "spatialReference" : {"wkid" : 4326} }, "extent" : { "xmin" :10, "ymin" : 10, "xmax" : 12, "ymax" : 12, "spatialReference" : {"wkid" : 4326} },
    "ClippingType": 1
    },
  "variableName" : "Raster"
}

"rasterFunction" : "Geometric"

//Added in 10.1

The arguments for the Geometric function are as shown below:

{
  "rasterFunction" : "Geometric",
  "rasterFunctionArguments" : {
    "GeodataTransforms" : <GeodataTransform>,//Please refer to the Geodata Transformations documentation for more details.
    "AppendGeodataXform" : <true|false>,//boolean
    "ZFactor" : <ZFactor>,//double
    "ZOffset" : <ZOffset>,//double
    "ConstantZ" : <ConstantZ>,//double
    "CorrectGeoid" : <true|false>//boolean
    },
  "variableName" : "Raster"
}

Example:

{
  "rasterFunction" : "Geometric",
  "rasterFunctionArguments" : {
    "GeodataTransforms" : [
        {
          geodataTransform" : "Polynomial",
          "geodataTransformArguments" : {
            "sourcePoints" : [ {"x":0.0, "y":0.0}, {"x":0.0, "y":200.0}, {"x":200.0, "y":0} ],
            "targetPoints" : [ {"x":100.0, "y":100.0}, {"x":100.0, "y":300.0}, {"x":300.0, "y":100.0} ],
            "polynomialOrder" : 1,
            "spatialReference": {"wkid" : 54004}
          }
        }
    ],
    "AppendGeodataXform" : true
  },
  "variableName" : "Raster"
}

Using a raster function template defined by the service

//Added in 10.1

The name of the raster function template is advertised in image service root resource. Function arguments are optional; argument names and default values are created by the author of the raster function template and are not known through REST. Client may simply provide the name of the raster function template only (to "RasterFunction" property), or optionally provide arguments to overwrite default values.

{
  "rasterFunction" : "rasterFunctionTemplateName",
}
{
  "rasterFunction" : "rasterFunctionTemplateName",
  "rasterFunctionArguments" : {
  "ArgumentName1":, //overwrite default value of ArgumentName1, type and default value are defined by the author of the template
  "ArgumentName2":, //overwrite default value of ArgumentName2, type and default value are defined by the author of the template
  ...
  },
  "variableName":"" //variableName can be other than "Raster", as defined by the author of the template
}

Example:

For a Landsat service that has a colorizedNDVI template defined, root resource will advertise:
"rasterFunctionInfos": [
 {
   "name": "LandsatColorizedNDVI",
   "description": "A raster function template for rendering NDVI with a nice pre-defined colormap",
   "help": "please refer to the help doc of this template http://myserver/LandsatColorizedNDVI.html."
  }
]
Client can use this function in the fullowing ways:
{
  "rasterFunction" : "LandsatColorizedNDVI"
}
{
  "rasterFunction" : "LandsatColorizedNDVI",
  "rasterFunctionArguments" : {
    "RedID" : 3, //argument name is defined by the author of the service, and is not available directly through REST. Help and usage may be provided by the publisher through the values of raster function template's description and help properties.
    "NIRID" : 4 //argument name is defined by the author of the service, and is not available directly through REST. Help and usage may be provided by the publisher through the values of raster function template's description and help properties.
  },
  "variableName" : "Raster"
}

Turn off default raster function template:

The first raster function template in rasterFunctionInfos in image service root resource is applied to exportImage request by default, when renderingRule is not specified in request. To turn it off, specify the following rendering rule.

{
  "rasterFunction" : "None",
}

If the first raster function template is "None", it means by default no rendering rule is used.