PixelBlock

AMD: require(["esri/layers/support/PixelBlock"], (PixelBlock) => { /* code goes here */ });
ESM: import PixelBlock from "@arcgis/core/layers/support/PixelBlock";
Class: esri/layers/support/PixelBlock
Inheritance: PixelBlock Accessor
Since: ArcGIS API for JavaScript 4.0

An object representing the pixel arrays in the view. It stores and decodes source data fetched from an image service associated with an ImageryLayer. This provides the user access to each pixel on the client via the pixels property. The PixelBlock object is designed to handle generic pixel arrays from any raster data source.

See also:

Constructors

new PixelBlock(properties)
Parameter:
properties Object
optional

See the properties for a list of all the properties that may be passed into the constructor.

Property Overview

Any properties can be set, retrieved or listened to. See the Working with Properties topic.
Show inherited properties Hide inherited properties
Name Type Summary Class
Stringmore details

The name of the class.

more detailsAccessor
Numbermore details

The height (or number of rows) of the PixelBlock in pixels.

more detailsPixelBlock
Number[]|Uint8Arraymore details

An array of nodata mask.

more detailsPixelBlock
Booleanmore details

Indicates whether mask should be used as alpha values.

more detailsPixelBlock
Number[][]|Int8Array[]|Uint8Array[]|Uint8ClampedArray[]|Int16Array[]|Uint16Array[]|Int32Array[]|Uint32Array[]|Float32Array[]|Float64Array[]more details

A two dimensional array representing the pixels from the Image Service displayed on the client.

more detailsPixelBlock
Stringmore details

The pixel type.

more detailsPixelBlock
Object[]more details

An array of objects containing numeric statistical properties.

more detailsPixelBlock
Numbermore details

Number of valid pixels

more detailsPixelBlock
Numbermore details

The width (or number of columns) of the PixelBlock in pixels.

more detailsPixelBlock

Property Details

declaredClass Stringreadonly inherited
Since: ArcGIS API for JavaScript 4.7

The name of the class. The declared class name is formatted as esri.folder.className.

height Number

The height (or number of rows) of the PixelBlock in pixels.

An array of nodata mask. All pixels are valid when mask is null.

maskIsAlpha Boolean

Indicates whether mask should be used as alpha values. If no (default), a pixel is valid when corresponding mask value is truthy

A two dimensional array representing the pixels from the Image Service displayed on the client. The length of the first dimension is the same as the number of bands in the layer. The length of the second dimension is height * width. The length of each band is the same. The pixels in each band are arranged row by row in this format: [p_00, p_10, p_20, ... p_10, p_11, ...] where p_xy is the pixel value at the column x and row y.

Example:
let pixels = imgLyr.pixelData.pixelBlock.pixels;
// Prints the number of bands in the layer
console.log(pixels.length);
// An array containing all the pixels in the first band
let band1 = pixels[0];
pixelType String

The pixel type.

Possible Values:"unknown"|"s8"|"s16"|"s32"|"u8"|"u16"|"u32"|"f32"|"f64"

statistics Object[]

An array of objects containing numeric statistical properties. Each object has the following specification if defined.

Properties:
maxValue Number
optional

The maximum pixel value in the pixels array.

minValue Number
optional

The minimum pixel value in the pixels array.

noDataValue Number
optional

Value representing areas of no data.

validPixelCount Number

Number of valid pixels

width Number

The width (or number of columns) of the PixelBlock in pixels.

Method Overview

Name Return Type Summary Class
more details

Adds another plane to the PixelBlock.

more detailsPixelBlock
Uint8ClampedArraymore details

Returns pixels and masks using a single array in bip format (e.g.

more detailsPixelBlock
Float32Arraymore details

Similar to getAsRGBA, but returns floating point data.

more detailsPixelBlock
Numbermore details

Returns the plane band count of the PixelBlock.

more detailsPixelBlock

Method Details

addData(planeData)

Adds another plane to the PixelBlock.

Parameters:
Specification:
planeData Object

The data to add to the PixelBlock.

Specification:
pixels Number[][]

A two dimensional array representing the pixels to add.

statistics Object[]

An array of objects containing numeric statistical properties. See statistics for details on the specifications of each object.

getAsRGBA(){Uint8ClampedArray}

Returns pixels and masks using a single array in bip format (e.g. [p_00_r, p_00_g, p_00_b, p_00_a, p_10_r, p_10_g, p_10_b, p_10_a, .....]). Use this method to get an unsigned 8 bit pixel array. The result can be used to create a webgl texture.

Returns:
Type Description
Uint8ClampedArray An unsigned 8-bit pixel array.
getAsRGBAFloat(){Float32Array}

Similar to getAsRGBA, but returns floating point data. The result can be used to create a webgl texture (OES_texture_float).

Returns:
Type Description
Float32Array A floating point array.
getPlaneCount(){Number}

Returns the plane band count of the PixelBlock.

Returns:
Type Description
Number The plane band count.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.