Show:

A representation of a RasterBand's pixels.

Note: Typed arrays should be created with an external ArrayBuffer for versions of node >= 0.11

var n = 16*16;
var data = new Float32Array(new ArrayBuffer(n*4));
//read data into the existing array
band.pixels.read(0,0,16,16,data);`

Methods

get
(
  • x
  • y
)
Number

Returns the value at the x, y coordinate.

Parameters:

  • x Integer
  • y Integer

Returns:

Number
read
(
  • x
  • y
  • width
  • height
  • [data] The [TypedArray]
  • options
)
TypedArray

Reads a region of pixels.

Parameters:

Returns:

TypedArray:

A TypedArray of values.

readAsync
(
  • x
  • y
  • width
  • height
  • [data] The [TypedArray]
  • options
  • callback
)
TypedArray

Asynchronously reads a region of pixels. If the last parameter is a callback, then this callback is called on completion and undefined is returned. All optional parameters before the callback can be omitted so the callback parameter can be at any position as long as it is the last parameter. Otherwise the function returns a Promise resolved with the result.

Parameters:

  • x Integer
  • y Integer
  • width Integer
  • height Integer
  • [data] The [TypedArray] TypedArray

    (https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView#Typed_array_subclasses) to put the data in. A new array is created if not given.

  • [options] Object optional
    • [buffer_width=x_size] Integer optional
    • [buffer_height=y_size] Integer optional
    • [data_type] String optional
    • [pixel_space] Integer optional
    • [line_space] Integer optional
  • [callback] RequestCallback optional

    Promisifiable callback, always the last parameter, can be specified even if certain optional parameters are omitted

Returns:

TypedArray:

A TypedArray of values.

readBlock
(
  • x
  • y
  • [data] The [TypedArray]
)
TypedArray

Reads a block of pixels.

Parameters:

Returns:

TypedArray:

A TypedArray of values.

set
(
  • x
  • y
  • value
)

Sets the value at the x, y coordinate.

Parameters:

  • x Integer
  • y Integer
  • value Number
write
(
  • x
  • y
  • width
  • height
  • data
  • options
)

Writes a region of pixels.

Parameters:

  • x Integer
  • y Integer
  • width Integer
  • height Integer
  • data TypedArray

    The TypedArray to write to the band.

  • [options] Object optional
    • [buffer_width=x_size] Integer optional
    • [buffer_height=y_size] Integer optional
    • [pixel_space] Integer optional
    • [line_space] Integer optional
writeAsync
(
  • x
  • y
  • width
  • height
  • data
  • options
  • callback
)

Asynchronously writes a region of pixels. If the last parameter is a callback, then this callback is called on completion and undefined is returned. All optional parameters before the callback can be omitted so the callback parameter can be at any position as long as it is the last parameter. Otherwise the function returns a Promise resolved with the result.

Parameters:

  • x Integer
  • y Integer
  • width Integer
  • height Integer
  • data TypedArray

    The TypedArray to write to the band.

  • [options] Object optional
    • [buffer_width=x_size] Integer optional
    • [buffer_height=y_size] Integer optional
    • [pixel_space] Integer optional
    • [line_space] Integer optional
  • [callback] RequestCallback optional

    Promisifiable callback, always the last parameter, can be specified even if certain optional parameters are omitted

writeBlock
(
  • x
  • y
  • data
)

Writes a block of pixels.

Parameters:

  • x Integer
  • y Integer
  • data TypedArray

    The TypedArray of values to write to the band.