Show:

A representation of an array with access methods.

Methods

asDataset
(
  • x
  • y
)
gdal.Dataset

Return a view of this array as a gdal.Dataset (ie 2D)

In the case of > 2D arrays, additional dimensions will be represented as raster bands.

Parameters:

  • x Number | String

    dimension to be used as X axis

  • y Number | String

    dimension to be used as Y axis

Returns:

getMask () gdal.MDArray

Return an array that is a mask for the current array.

This array will be of type Byte, with values set to 0 to indicate invalid pixels of the current array, and values set to 1 to indicate valid pixels.

The generic implementation honours the NoDataValue, as well as various netCDF CF attributes: missing_value, _FillValue, valid_min, valid_max and valid_range.

Returns:

getView
(
  • view
)
gdal.MDArray

Get a partial view of the MDArray

The slice expression uses the same syntax as NumPy basic slicing and indexing. See (https://www.numpy.org/devdocs/reference/arrays.indexing.html#basic-slicing-and-indexing). Or it can use field access by name. See (https://www.numpy.org/devdocs/reference/arrays.indexing.html#field-access).

Parameters:

  • view String

Returns:

read
(
  • options
)
TypedArray

Read data from the MDArray

This will extract the context of a (hyper-)rectangle from the array into a buffer. If the buffer can be passed as an argument or it can be allocated by the function. Generalized n-dimensional strides are supported.

Although this method can be used in its raw form, it works best when used with the ndarray plugin.

Parameters:

Returns:

TypedArray
readAsync
(
  • options
  • callback=undefined
)
Promise

Read data from the MDArray. 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.

This will extract the context of a (hyper-)rectangle from the array into a buffer. If the buffer can be passed as an argument or it can be allocated by the function. Generalized n-dimensional strides are supported.

Although this method can be used in its raw form, it works best when used with the ndarray plugin.

Parameters:

  • options MDArrayOptions
    • origin Number[]

      An array of the starting indices

    • span Number[]

      An array specifying the number of elements to read in each dimension

    • [stride] Number[] optional

      An array of strides for the output array, mandatory if the array is specified

    • [data_type] String optional
    • [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.

    • [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.

Attributes

attributes

gdal.ArrayAttributes readonly

dataType

String readonly

description

String readonly

dimensions

gdal.GroupDimensions readonly

length

Number readonly

The flattened length of the array

noDataValue

Number | Null

No data value for this array.

offset

Number

Raster value offset.

scale

Number

Raster value scale.

srs

gdal.SpatialReference

Spatial reference associated with MDArray

unitType

String

Raster unit type (name for the units of this raster's values). For instance, it might be "m" for an elevation model in meters, or "ft" for feet. If no units are available, a value of "" will be returned.