You are using a browser that is no longer supported. Please use the latest version of Google Chrome, Mozilla Firefox, Apple Safari, or Microsoft Edge. For more information please see the System Requirements.
Skip To ContentArcGIS for DevelopersSign In Dashboard

Unsupported browser

You are using a browser that is not supported. JavaScript API works on the latest versions of Google Chrome, Mozilla Firefox, Apple Safari, or Microsoft Edge. Use one of these browsers and provide your feedback through GeoNet, the Esri Community.

  • {}
  • Firefox
  • Safari
  • undefined

Note: Support for 3D on mobile devices may vary, view the system requirements for more information.

This sample shows how to use the attribute table of an ImageryLayer to mask pixels from display. The pixelFilter property of the layer allows the developer to add color to each pixel using RGB values and exclude unwanted pixels.

This layer contains land cover data. Each pixel value represents a land cover type and has attributes associated with it available via the raster attribute table in the image service. This sample displays the desert areas in the western United States by only displaying pixels with values of Shrub/Scrub or Barren Land.

// to get the raster attribute table, you first must
// wait for the layer to be ready
layer.when(function() {
  rasterAttributes = layer.serviceRasterInfo.attributeTable.features;

  // Get the objects storing field information for
  // pixels classified as Barren Land and "Shrub/Scrub"

  fields = rasterAttributes.filter(function(item, i) {
    var className = item.attributes.ClassName;
    return className === "Barren Land" || className === "Shrub/Scrub";

Once you have the fields of interest, you can use the pixel filter to exclude unwanted pixels with the mask property of the pixel block and color the desired pixels with either the preset color scheme or any other desired color scheme.

Sample search results