Skip To Content

Compute Histograms

  • URL:https://<imageservice-url>/computeHistograms
  • Required Capability:Image
  • Version Introduced:10.1

Description

This operation is supported at 10.1 and later.

The computeHistograms operation is performed on an image service resource.

This operation is supported by an image service published with mosaic datasets or a raster dataset.

The result of this operation is an array of histograms for all raster bands computed from the given extent.

Support for the time parameter is added at 10.8. The time parameter can be used on an image service resource that uses ArcObjects11 or ArcObjectsRasterRendering as the service provider.

Support for the processAsMultidimensional parameter is added at 10.9. The processAsMultidimensional parameter can be used on an image service resource that uses ArcObjects11 or ArcObjectsRasterRendering as the service provider.

You can provide arguments to the computeHistograms operation as query parameters defined in the parameters table below.

Request parameters

ParameterDescription
geometry

(Required)

Defines the geometry in which the histogram is computed. The geometry can be an envelope or a polygon. The structure of the geometry is the same as the structure of the JSON geometry objects returned by the ArcGIS REST API.

JSON structures:

Syntax: geometry={geometry}

Example: geometry={"xmin" : -109.55, "ymin" : 25.76, "xmax" : -86.39, "ymax" : 49.94, "spatialReference" : {"wkid" : 4326}}

geometryType

(Required)

The type of geometry specified by the geometry parameter. The geometry type can be an envelope or polygon.

Values: esriGeometryEnvelope | esriGeometryPolygon

mosaicRule

Specifies the mosaic rule when defining how individual images will be mosaicked. When a mosaic rule is not specified, the default mosaic rule of the image service will be used (as specified in the root resource: defaultMosaicMethod, mosaicOperator, sortField, sortValue).

See the mosaic rule JSON objects for the syntax and examples.

renderingRule

Specifies the rendering rule for how the requested image will be rendered.

See the raster function JSON objects for the syntax and examples.

pixelSize

The pixel level being used (or the resolution being looked at). If pixel size is not specified, pixelSize will default to the base resolution of the dataset. The raster at the specified pixel size in the mosaic dataset will be used for histogram calculation.

The structure of the pixelSize parameter is the same as the structure of the point object returned by the ArcGIS REST API. In addition to the JSON structure, you can specify the pixel size with a simple comma-separated syntax.

Syntax:

  • JSON structure: pixelSize={point}
  • Point simple syntax: pixelSize=<x>,<y>

Examples:

  • pixelSize={"x": 0.18, "y": 0.18}
  • pixelSize=0.18,0.18

time

The time instant or the time extent to compute the histogram. Time is designated in UNIX Epoch time, or POSIX time, in milliseconds.

Time instant:

  • Syntax: time=<timeInstant>

  • Example: time=1199145600000 (1 Jan 2008 00:00:00 GMT)

Time extent (for time extents, one of <startTime> or <endTime> can be 'null'):

  • Syntax: time=<startTime>, <endTime>

  • Example: time=1199145600000, 1230768000000 (1 Jan 2008 00:00:00 GMT to 1 Jan 2009 00:00:00 GMT)

    A null value specified for start time or end time will represent infinity for start or end time, respectively.

processAsMultidimensional

Specifies whether to process the image service as a multidimensional image service. When set to true, the image service is treated as a multidimensional raster, and histograms of pixel values from all selected slices are computed. When set to false, the histogram of pixel values from only the first slice is computed. The default is false.

Values: true|false

Example: processAsMultidimensional=true

f

The response format. The default response format is html.

Values: html | json

Example usage

Example: Compute histograms of a mosaic dataset image service using a polygon geometry, and specify the mosaic rule using the esriMosaicAttribute method.

https://webadaptorhost.domain.com/webadaptorname/rest/services/myservice/ImageServer/computeHistograms?geometry={"rings": [[[-13555360.4191,5911556.581],[-13489311.5669, 5898227.932],[-13423477.4153,5884426.3329],[-13602646.9571, 5717848.4135], [-13587119.9125, 5781976.6214],[-13571360.1713, 5846543.2654],[-13555360.4191, 5911556.581]]]}&geometryType=esriGeometryPolygon &mosaicRule=&f=html

JSON Response syntax


            "histograms" : [ 
    <histogram1>, <histogram2>
  ]

JSON Response example


            {
 "histograms": [
    {
      "size" : 256, 
      "min" : -0.5, 
      "max" : 255.5, 
      "counts" : [
        42915, 
        23218, 
        24832, 
        25925 
        36054, 
        57097, 
        61278, 
        65211
        ...
        ]
   },
   {
      "size" : 256, 
      "min" : -0.5, 
      "max" : 255.5, 
      "counts" : [
        42915, 
        23218, 
        24832, 
        25925 
        36054, 
        57097, 
        61278, 
        65211
        ...
        ]
   },
   {
      "size" : 256, 
      "min" : -0.5, 
      "max" : 255.5, 
      "counts" : [
        42915, 
        23218, 
        24832, 
        25925 
        36054, 
        57097, 
        61278, 
        65211
        ...
        ]
   }
}