Show:

A set of associated raster bands and/or vector layers, usually from one file.

// raster dataset:
dataset = gdal.open('file.tif');
bands = dataset.bands;

// vector dataset:
dataset = gdal.open('file.shp');
layers = dataset.layers;`

Methods

buildOverviews
(
  • resampling
  • overviews
  • bands
  • options
)

Builds dataset overviews.

Parameters:

  • resampling String

    "NEAREST", "GAUSS", "CUBIC", "AVERAGE", "MODE", "AVERAGE_MAGPHASE" or "NONE"

  • overviews Number[]
  • [bands] Number[] optional

    Note: Generation of overviews in external TIFF currently only supported when operating on all bands.

  • [options] ProgressOptions optional

    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.

buildOverviewsAsync
(
  • resampling
  • overviews
  • bands
  • options
  • callback=undefined
)
Promise

Builds dataset overviews. 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:

  • resampling String

    "NEAREST", "GAUSS", "CUBIC", "AVERAGE", "MODE", "AVERAGE_MAGPHASE" or "NONE"

  • overviews Number[]
  • [bands] Number[] optional

    Note: Generation of overviews in external TIFF currently only supported when operating on all bands.

  • [options] ProgressOptions optional

    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.

Returns:

Promise
close ()

Closes the dataset to further operations. It releases all memory and ressources held by the dataset. This is normally an instantenous atomic operation that won't block the event loop except if there is an operation running on this dataset in asynchronous context - in this case this call will block until that operation finishes.

If this could potentially be the case and blocking the event loop is not possible (server code), then the best option is to simply dereference it (ds = null) and leave the garbage collector to expire it.

Implementing an asynchronous delete is difficult since all V8 object creation/deletion must take place on the main thread.

flushAsync ensures that, when writing, all data has been written.

executeSQL
(
  • statement
  • spatial_filter=null
  • dialect=null
)
gdal.Layer

Execute an SQL statement against the data store.

Parameters:

  • statement String

    SQL statement to execute.

  • [spatial_filter=null] gdal.Geometry optional

    Geometry which represents a spatial filter.

  • [dialect=null] String optional

    Allows control of the statement dialect. If set to null, the OGR SQL engine will be used, except for RDBMS drivers that will use their dedicated SQL engine, unless "OGRSQL" is explicitely passed as the dialect. Starting with OGR 1.10, the "SQLITE" dialect can also be used.

Returns:

executeSQLAsync
(
  • statement
  • spatial_filter=null
  • dialect=null
  • callback=undefined
)
Promise

Execute an SQL statement against the data store. 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:

  • statement String

    SQL statement to execute.

  • [spatial_filter=null] gdal.Geometry optional

    Geometry which represents a spatial filter.

  • [dialect=null] String optional

    Allows control of the statement dialect. If set to null, the OGR SQL engine will be used, except for RDBMS drivers that will use their dedicated SQL engine, unless "OGRSQL" is explicitely passed as the dialect. Starting with OGR 1.10, the "SQLITE" dialect can also be used.

  • [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
flush ()

Flushes all changes to disk.

flushAsync
(
  • callback=undefined
)
Promise

Flushes all changes to disk. 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:

  • [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
getFileList () String[]

Fetch files forming dataset.

Returns a list of files believed to be part of this dataset. If it returns an empty list of files it means there is believed to be no local file system files associated with the dataset (for instance a virtual dataset).

Returns an empty array for vector datasets if GDAL version is below 2.0

Returns:

String[]
getGCPProjection () String

Get output projection for GCPs.

Returns:

String
getGCPs () Any[]

Fetches GCPs.

Returns:

Any[]
getMetadata
(
  • domain
)
Any

Fetch metadata.

Parameters:

  • [domain] String optional

Returns:

Any
getMetadataAsync
(
  • domain
  • callback=undefined
)
Promise

Fetch metadata. 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:

  • [domain] String optional
  • [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
setGCPs
(
  • gcps
  • projection
)

Sets GCPs.

Parameters:

  • gcps Object[]
  • [projection] String optional
setMetadata
(
  • metadata
  • domain
)
Boolean

Set metadata. Can return a warning (false) for formats not supporting persistent metadata.

Parameters:

  • metadata Object | String[]
  • [domain] String optional

Returns:

Boolean
setMetadataAsync
(
  • metadata
  • domain
  • callback=undefined
)
Promise

Set metadata. Can return a warning (false) for formats not supporting persistent metadata. 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:

  • metadata Object | String[]
  • [domain] String optional
  • [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
testCapability
(
  • capability
)
Boolean

Determines if the dataset supports the indicated operation.

Parameters:

Returns:

Boolean

Attributes

bands

gdal.DatasetBands readonly

description

String readonly

driver

gdal.Driver readonly

geoTransform

Number | Null

An affine transform which maps pixel/line coordinates into georeferenced space using the following relationship:

Example:

var GT = dataset.geoTransform;
var Xgeo = GT[0] + Xpixel*GT[1] + Yline*GT[2];
var Ygeo = GT[3] + Xpixel*GT[4] + Yline*GT[5];`

geoTransformAsync

Promise readonly

An affine transform which maps pixel/line coordinates into georeferenced space using the following relationship:

Example:

var GT = dataset.geoTransform;
var Xgeo = GT[0] + Xpixel*GT[1] + Yline*GT[2];
var Ygeo = GT[3] + Xpixel*GT[4] + Yline*GT[5];`


Asynchronous read-only getter. Returns a Promise that resolves with the result.

layers

gdal.DatasetLayers readonly

rasterSize

Xyz readonly

Raster dimensions. An object containing x and y properties.

rasterSizeAsync

Promise readonly

Raster dimensions. An object containing x and y properties. Asynchronous read-only getter. Returns a Promise that resolves with the result.

root

gdal.Group readonly

srs

gdal.SpatialReference | Null

Spatial reference associated with raster dataset

srsAsync

Promise readonly

Spatial reference associated with raster dataset Asynchronous read-only getter. Returns a Promise that resolves with the result.