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

clampBlock
(
  • x
  • y
)
Xyz

Clamp the block size for a given block offset. Handles partial blocks at the edges of the raster and returns the true number of pixels.

Parameters:

  • x Number
  • y Number

Returns:

Xyz:

A size object.

clampBlockAsync
(
  • x
  • y
  • callback=undefined
)
Promise

Clamp the block size for a given block offset. Handles partial blocks at the edges of the raster and returns the true number of pixels. Asynchronous version. 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 Number
  • y Number
  • [callback=undefined] Callback optional

    standard Node.js (error, result) callback. It is always the last parameter and can be specified even if certain optional parameters are omitted. On error error is an Error object and result is undefined. On success error is null and result contains the result. The function returns a Promise when the callback is undefined. The return value is undefined when a callback is provided. Argument type errors are thrown synchronously even when a callback is provided. In Promise mode all errors result in a rejected Promise.

Returns:

Promise:

A size object.

createReadStream
(
  • options
)
RasterReadStream

Defined in lib/readable.js:7

create a Readable stream from a raster band

Parameters:

  • [options] RasterReadableOptions optional
    • [blockOptimize=true] Boolean optional

      Read by file blocks when possible (when rasterSize.x == blockSize.x)

    • [convertNoData=true] Boolean optional

      Automatically convert gdal.RasterBand.noDataValue to NaN

    • [readAs=undefined] New (len: number) => TypedArray optional

      Data type to convert to, must be a TypedArray constructor

Returns:

RasterReadStream
createWriteStream
(
  • options
)
RasterWriteStream

Defined in lib/writable.js:7

create a Writable stream from a raster band

Parameters:

  • [options] RasterWritableOptions optional
    • [blockOptimize=true] Boolean optional

      Write by file blocks when possible (when rasterSize.x == blockSize.x)

    • [convertNoData=true] Boolean optional

      Automatically convert NaN to gdal.RasterBand.noDataValue if it is set

Returns:

RasterWriteStream
get
(
  • x
  • y
)
Number

Returns the value at the x, y coordinate.

Parameters:

  • x Number
  • y Number

Returns:

Number
getAsync
(
  • x
  • y
  • callback=undefined
)
Promise

Returns the value at the x, y coordinate. Asynchronous version. 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 Number
  • y Number
  • [callback=undefined] Callback optional

    standard Node.js (error, result) callback. It is always the last parameter and can be specified even if certain optional parameters are omitted. On error error is an Error object and result is undefined. On success error is null and result contains the result. The function returns a Promise when the callback is undefined. The return value is undefined when a callback is provided. Argument type errors are thrown synchronously even when a callback is provided. In Promise mode all errors result in a rejected Promise.

Returns:

Promise
read
(
  • x
  • y
  • width
  • height
  • data
  • options
)
TypedArray

Reads a region of pixels.

Parameters:

  • x Number
  • y Number
  • width Number
  • height Number
  • [data] TypedArray optional

    The 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] ReadOptions optional
    • [buffer_width=x_size] Number optional
    • [buffer_height=y_size] Number optional
    • [data_type] String optional
    • [pixel_space] Number optional
    • [line_space] Number optional
    • [resampling] String optional

      Resampling algorithm (available options)

    • [progress_cb] ProgressCb optional

      optional progress callback. In sync mode at every invocation it will stop the GDAL operation until it returns. In async mode it will schedule the invocation to be executed at the next event loop iteration while the GDAL operation will continues in the background. If the event loop is blocked and a second invocation is scheduled before the first one has been executed, the first one will be discarded. No progress callbacks will be delivered after the result callback has been triggered or the Promise has been resolved. If the event loop is blocked for the whole duration of the operation, no progress callbacks will be made at all. The callback takes two arguments, the first one, complete, is a number between 0 and 1 indicating the progress towards the operation finish and the second one, message, can be used by certain GDAL drivers to return text messages.

readAsync
(
  • x
  • y
  • width
  • height
  • data
  • options
  • callback=undefined
)
Promise

Asynchronously reads a region of pixels. Asynchronous version. 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 Number
  • y Number
  • width Number

    the width

  • height Number
  • [data] TypedArray optional

    The 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] ReadOptions optional
    • [buffer_width=x_size] Number optional
    • [buffer_height=y_size] Number optional
    • [data_type] String optional
    • [pixel_space] Number optional
    • [line_space] Number optional
    • [resampling] String optional

      Resampling algorithm (available options)

    • [progress_cb] ProgressCb optional

      optional progress callback. In sync mode at every invocation it will stop the GDAL operation until it returns. In async mode it will schedule the invocation to be executed at the next event loop iteration while the GDAL operation will continues in the background. If the event loop is blocked and a second invocation is scheduled before the first one has been executed, the first one will be discarded. No progress callbacks will be delivered after the result callback has been triggered or the Promise has been resolved. If the event loop is blocked for the whole duration of the operation, no progress callbacks will be made at all. The callback takes two arguments, the first one, complete, is a number between 0 and 1 indicating the progress towards the operation finish and the second one, message, can be used by certain GDAL drivers to return text messages.

  • [callback=undefined] Callback optional

    standard Node.js (error, result) callback. It is always the last parameter and can be specified even if certain optional parameters are omitted. On error error is an Error object and result is undefined. On success error is null and result contains the result. The function returns a Promise when the callback is undefined. The return value is undefined when a callback is provided. Argument type errors are thrown synchronously even when a callback is provided. In Promise mode all errors result in a rejected Promise.

readBlock
(
  • x
  • y
  • data
)
TypedArray

Reads a block of pixels.

Parameters:

readBlockAsync
(
  • x
  • y
  • data
  • callback=undefined
)
Promise

Reads a block of pixels. Asynchronous version. 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 Number
  • y Number
  • [data] TypedArray optional

    The 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.

  • [callback=undefined] Callback optional

    standard Node.js (error, result) callback. It is always the last parameter and can be specified even if certain optional parameters are omitted. On error error is an Error object and result is undefined. On success error is null and result contains the result. The function returns a Promise when the callback is undefined. The return value is undefined when a callback is provided. Argument type errors are thrown synchronously even when a callback is provided. In Promise mode all errors result in a rejected Promise.

set
(
  • x
  • y
  • value
)

Sets the value at the x, y coordinate.

Parameters:

  • x Number
  • y Number
  • value Number
setAsync
(
  • x
  • y
  • value
  • callback=undefined
)
Promise

Sets the value at the x, y coordinate. Asynchronous version. 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 Number
  • y Number
  • value Number
  • [callback=undefined] Callback optional

    standard Node.js (error, result) callback. It is always the last parameter and can be specified even if certain optional parameters are omitted. On error error is an Error object and result is undefined. On success error is null and result contains the result. The function returns a Promise when the callback is undefined. The return value is undefined when a callback is provided. Argument type errors are thrown synchronously even when a callback is provided. In Promise mode all errors result in a rejected Promise.

Returns:

Promise
write
(
  • x
  • y
  • width
  • height
  • data
  • options
)

Writes a region of pixels.

Parameters:

  • x Number
  • y Number
  • width Number
  • height Number
  • [data] TypedArray optional
  • [options] WriteOptions optional
    • [buffer_width=x_size] Number optional
    • [buffer_height=y_size] Number optional
    • [pixel_space] Number optional
    • [line_space] Number optional
    • [progress_cb] ProgressCb optional

      optional progress callback. In sync mode at every invocation it will stop the GDAL operation until it returns. In async mode it will schedule the invocation to be executed at the next event loop iteration while the GDAL operation will continues in the background. If the event loop is blocked and a second invocation is scheduled before the first one has been executed, the first one will be discarded. No progress callbacks will be delivered after the result callback has been triggered or the Promise has been resolved. If the event loop is blocked for the whole duration of the operation, no progress callbacks will be made at all. The callback takes two arguments, the first one, complete, is a number between 0 and 1 indicating the progress towards the operation finish and the second one, message, can be used by certain GDAL drivers to return text messages.

writeAsync
(
  • x
  • y
  • width
  • height
  • data
  • options
  • callback=undefined
)
Promise

Asynchronously writes a region of pixels. Asynchronous version. 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 Number
  • y Number
  • width Number
  • height Number
  • [data] TypedArray optional
  • [options] WriteOptions optional
    • [buffer_width=x_size] Number optional
    • [buffer_height=y_size] Number optional
    • [pixel_space] Number optional
    • [line_space] Number optional
    • [progress_cb] ProgressCb optional

      optional progress callback. In sync mode at every invocation it will stop the GDAL operation until it returns. In async mode it will schedule the invocation to be executed at the next event loop iteration while the GDAL operation will continues in the background. If the event loop is blocked and a second invocation is scheduled before the first one has been executed, the first one will be discarded. No progress callbacks will be delivered after the result callback has been triggered or the Promise has been resolved. If the event loop is blocked for the whole duration of the operation, no progress callbacks will be made at all. The callback takes two arguments, the first one, complete, is a number between 0 and 1 indicating the progress towards the operation finish and the second one, message, can be used by certain GDAL drivers to return text messages.

  • [callback=undefined] Callback optional

    standard Node.js (error, result) callback. It is always the last parameter and can be specified even if certain optional parameters are omitted. On error error is an Error object and result is undefined. On success error is null and result contains the result. The function returns a Promise when the callback is undefined. The return value is undefined when a callback is provided. Argument type errors are thrown synchronously even when a callback is provided. In Promise mode all errors result in a rejected Promise.

Returns:

Promise
writeBlock
(
  • x
  • y
  • data
)

Writes a block of pixels.

Parameters:

writeBlockAsync
(
  • x
  • y
  • data
  • callback=undefined
)
Promise

Writes a block of pixels. Asynchronous version. 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 Number
  • y Number
  • data TypedArray
  • [callback=undefined] Callback optional

    standard Node.js (error, result) callback. It is always the last parameter and can be specified even if certain optional parameters are omitted. On error error is an Error object and result is undefined. On success error is null and result contains the result. The function returns a Promise when the callback is undefined. The return value is undefined when a callback is provided. Argument type errors are thrown synchronously even when a callback is provided. In Promise mode all errors result in a rejected Promise.

Returns:

Promise

Attributes

band

gdal.RasterBand readonly

Parent raster band