Show:

This node-gdal-async binding for Node.js provides a feature-complete way of reading, writing, and manipulating geospatial data, raster and vector, synchronously and asynchronously using GDAL.

// sample: open a shapefile and display all features as geojson
const dataset = gdal.open("states.shp");

dataset.layers.get(0).features.forEach(function(feature) {
    console.log(feature.getGeometry().toJSON());
});
// same thing, but asynchronously, allowing integration in server-side multi-user code
const dataset = await gdal.openAsync("states.shp");
const features = (await dataset.layers.getAsync(0)).features;
const len = await features.countAsync();

for (let i = t; i < len; i++) {
  features.getAsync(i, (error, feature) => {
    console.log(feature.getGeometry().toJSON());
  });
}

see ASYNCIO.md for some performance considerations when designing code that will run multiple parallel operations on the same dataset

Methods

fromDataType
(
  • dataType
)
New (len: number) => TypedArray

Defined in lib/gdal.js:145

Returns a TypedArray (https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView#Typed_array_subclasses) constructor from a GDAL data type

Parameters:

  • dataType String | Null

Returns:

New (len: number) => TypedArray

Example:

const array = new (gdal.fromDataType(band.dataType))(band.size.x * band.size.y)
toDataType
(
  • array
)
String

Defined in lib/gdal.js:175

Parameters:

  • array TypedArray

Returns:

String

Example:

const dataType = gdal.fromDataType(array)

Properties

gdal.bundled

Boolean const

GDAL library - system library (false) or bundled (true)

gdal.drivers

gdal.GDALDrivers const

The collection of all drivers registered with GDAL

gdal.eventLoopWarning

Boolean

Should a warning be emitted to stderr when a synchronous operation is blocking the event loop, can be safely disabled unless the user application needs to remain responsive at all times Use (gdal as any).eventLoopWarning = false to set the value from TypeScript

gdal.lastError

Object const

Details about the last error that occurred. The property will be null or an object containing three properties: "number", "message", and "type".

gdal.version

String const

GDAL version (not the binding version)

Attributes

lastError

Object

Static Methods

gdal.calcAsync
(
  • inputs
  • output
  • fn
  • options
)
Promise

Defined in lib/calc.js:1

Compute a new output band as a pixel-wise function of given input bands

This is an alternative implementation of gdal_calc.py

It is fully async and reading and decoding of input and output bands happen in separate background threads for each band as long as they are in separate datasets.

The main bottleneck is the passed function fn which must always run on the main Node.js/V8 thread. This is a fundamental Node.js/V8 limitation that is impossible to overcome.

This function is not to be used in server code that must remain responsive at all times. It does not directly block the event loop, but it is very CPU-heavy and cannot run parallel to other instances of itself. If multiple instances run in parallel, they will all compete for the main thread, executing fn on the incoming data chunks on turn by turn basis.

There is no sync version

Parameters:

  • inputs Record

    An object containing all the input bands

  • output gdal.RasterBand

    Output raster band

  • fn (...args: number) => number[]

    Function to apply on all pixels, it must have the same number of arguments as there are input bands

  • [options] CalcOptions optional

    Options

    • [convertNoData=false] Boolean optional

      Input bands will have their NoData pixels converted to NaN and a NaN output value of the given function will be converted to a NoData pixel, provided that the output raster band has its gdal.RasterBand.noDataValue set

Returns:

Promise

Example:

const T2m = await gdal.openAsync('TEMP_2M.tiff'));
const D2m = await gdal.openAsync('DEWPOINT_2M.tiff'));
const size = await T2m.rasterSizeAsync
const cloudBase = await gdal.openAsync('CLOUDBASE.tiff', 'w', 'GTiff',
   size.x, size.y, 1, gdal.GDT_Float64);

(await cloudBase.bands.getAsync(1)).noDataValue = -1e38
// Espy's estimation for cloud base height
const espyFn = (t, td) => 125 * (t - td);

await calcAsync({
 t: await T2m.bands.getAsync(1),
 td: await D2m.bands.getAsync(1)
}, cloudBase.bands.getAsync(1), espyFn, { convertNoData: true });
gdal.checksumImage
(
  • src
  • x=0
  • y=0
  • w=src.width
  • h=src.height
)
Number

Compute checksum for image region.

Parameters:

  • src gdal.RasterBand
  • [x=0] Number optional
  • [y=0] Number optional
  • [w=src.width] Number optional
  • [h=src.height] Number optional

Returns:

Number
gdal.checksumImageAsync
(
  • src
  • x=0
  • y=0
  • w=src.width
  • h=src.height
  • callback=undefined
)
Promise

Compute checksum for image region.

Parameters:

  • src gdal.RasterBand
  • [x=0] Number optional
  • [y=0] Number optional
  • [w=src.width] Number optional
  • [h=src.height] Number 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
gdal.contourGenerate
(
  • options
)

Create vector contours from raster DEM.

This algorithm will generate contour vectors for the input raster band on the requested set of contour levels. The vector contours are written to the passed in vector layer. Also, a NODATA value may be specified to identify pixels that should not be considered in contour line generation.

Parameters:

  • options ContourOptions
    • src gdal.RasterBand
    • dst gdal.Layer
    • [offset=0] Number optional

      The "offset" relative to which contour intervals are applied. This is normally zero, but could be different. To generate 10m contours at 5, 15, 25, ... the offset would be 5.

    • [interval=100] Number optional

      The elevation interval between contours generated.

    • [fixedLevels] Number[] optional

      A list of fixed contour levels at which contours should be generated. Overrides interval/base options if set.

    • [nodata] Number optional

      The value to use as a "nodata" value. That is, a pixel value which should be ignored in generating contours as if the value of the pixel were not known.

    • [idField] Number optional

      A field index to indicate where a unique id should be written for each feature (contour) written.

    • [elevField] Number optional

      A field index to indicate where the elevation value of the contour should be written.

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

gdal.contourGenerateAsync
(
  • options
  • callback=undefined
)
Promise

Create vector contours from raster DEM. 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 algorithm will generate contour vectors for the input raster band on the requested set of contour levels. The vector contours are written to the passed in vector layer. Also, a NODATA value may be specified to identify pixels that should not be considered in contour line generation.

Parameters:

  • options ContourOptions
    • src gdal.RasterBand
    • dst gdal.Layer
    • [offset=0] Number optional

      The "offset" relative to which contour intervals are applied. This is normally zero, but could be different. To generate 10m contours at 5, 15, 25, ... the offset would be 5.

    • [interval=100] Number optional

      The elevation interval between contours generated.

    • [fixedLevels] Number[] optional

      A list of fixed contour levels at which contours should be generated. Overrides interval/base options if set.

    • [nodata] Number optional

      The value to use as a "nodata" value. That is, a pixel value which should be ignored in generating contours as if the value of the pixel were not known.

    • [idField] Number optional

      A field index to indicate where a unique id should be written for each feature (contour) written.

    • [elevField] Number optional

      A field index to indicate where the elevation value of the contour should be written.

    • [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
gdal.decToDMS
(
  • angle
  • axis
  • precision=2
)
String

Convert decimal degrees to degrees, minutes, and seconds string

Parameters:

  • angle Number
  • axis String

    "lat" or "long"

  • [precision=2] Number optional

Returns:

String:

A string nndnn'nn.nn'"L where n is a number and L is either N or E

gdal.fillNodata
(
  • options
)

Fill raster regions by interpolation from edges.

Parameters:

  • options FillOptions
    • src gdal.RasterBand

      This band to be updated in-place.

    • [mask] gdal.RasterBand optional

      Mask band

    • searchDist Number

      The maximum distance (in pixels) that the algorithm will search out for values to interpolate.

    • [smoothingIterations=0] Number optional

      The number of 3x3 average filter smoothing iterations to run after the interpolation to dampen artifacts.

gdal.fillNodataAsync
(
  • options
  • callback=undefined
)
Promise

Fill raster regions by interpolation from edges. 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:

  • options FillOptions
    • src gdal.RasterBand

      This band to be updated in-place.

    • [mask] gdal.RasterBand optional

      Mask band

    • searchDist Number

      The maximum distance (in pixels) that the algorithm will search out for values to interpolate.

    • [smoothingIterations=0] Number optional

      The number of 3x3 average filter smoothing iterations to run after the interpolation to dampen artifacts.

  • [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
gdal.info
(
  • dataset
  • args
)
String

Library version of gdalinfo.

Parameters:

  • dataset gdal.Dataset
  • [args] String[] optional

    array of CLI options for gdalinfo

Returns:

String

Example:

const ds = gdal.open('input.tif') const output = gdal.info('/vsimem/temp.tif')

gdal.infoAsync
(
  • dataset
  • args
  • callback=undefined
)
Promise

Library version of gdalinfo. 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:

  • dataset gdal.Dataset
  • [args] String[] optional

    array of CLI options for gdalinfo

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

Example:

const ds = gdal.open('input.tif') const output = gdal.info('/vsimem/temp.tif')

gdal.open
(
  • path
  • mode="r"
  • drivers
  • x_size
  • y_size
  • band_count
  • data_type
  • creation_options
)
Dataset

Defined in lib/gdal.js:232

Creates or opens a dataset. Dataset should be explicitly closed with dataset.close() method if opened in "w" mode to flush any changes. Otherwise, datasets are closed when (and if) node decides to garbage collect them.

Parameters:

  • path String | Buffer

    Path to dataset or in-memory Buffer to open

  • [mode="r"] String optional

    The mode to use to open the file: "r", "r+", or "w"

  • [drivers] String | String[] optional

    Driver name, or list of driver names to attempt to use.

  • [x_size] Number optional

    Used when creating a raster dataset with the "w" mode.

  • [y_size] Number optional

    Used when creating a raster dataset with the "w" mode.

  • [band_count] Number optional

    Used when creating a raster dataset with the "w" mode.

  • [data_type] String optional

    Used when creating a raster dataset with the "w" mode.

  • [creation_options] String[] | Object optional

    Used when creating a dataset with the "w" mode.

Returns:

Dataset

Example:

var dataset = gdal.open('./data.shp');`
var dataset = gdal.open(fs.readFileSync('./data.shp'));`
gdal.openAsync
(
  • path
  • mode="r"
  • drivers
  • x_size
  • y_size
  • band_count
  • data_type
  • creation_options
  • callback=undefined
)
Promise

Defined in lib/gdal.js:329

Asynchronously creates or opens a dataset. Dataset should be explicitly closed with dataset.close() method if opened in "w" mode to flush any changes. Otherwise, datasets are closed when (and if) node decides to garbage collect them. If the last parameter is a callback, then this callback is called on completion and undefined is returned. Otherwise the function returns a Promise resolved with the result.

Parameters:

  • path String | Buffer

    Path to dataset or in-memory Buffer to open

  • [mode="r"] String optional

    The mode to use to open the file: "r", "r+", or "w"

  • [drivers] String | String[] optional

    Driver name, or list of driver names to attempt to use.

  • [x_size] Number optional

    Used when creating a raster dataset with the "w" mode.

  • [y_size] Number optional

    Used when creating a raster dataset with the "w" mode.

  • [band_count] Number optional

    Used when creating a raster dataset with the "w" mode.

  • [data_type] String optional

    Used when creating a raster dataset with the "w" mode.

  • [creation_options] String[] | Object optional

    Used when creating a dataset with the "w" mode.

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

Example:

var dataset = await gdal.openAsync('./data.shp');`
var dataset = await gdal.openAsync(await fd.readFile('./data.shp'));`
gdal.openAsync('./data.shp', (err, ds) => {...});`
gdal.openAsync
(
  • path
  • callback
)
Void

Defined in lib/gdal.js:361

TypeScript shorthand version with callback and no optional arguments

Parameters:

  • path String | Buffer

    Path to dataset or in-memory Buffer to open

  • callback Callback

    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:

Void
gdal.polygonize
(
  • options
)

Creates vector polygons for all connected regions of pixels in the raster sharing a common pixel value. Each polygon is created with an attribute indicating the pixel value of that polygon. A raster mask may also be provided to determine which pixels are eligible for processing.

Parameters:

  • options PolygonizeOptions
    • src gdal.RasterBand
    • dst gdal.Layer
    • [mask] gdal.RasterBand optional
    • pixValField Number

      The attribute field index indicating the feature attribute into which the pixel value of the polygon should be written.

    • [connectedness=4] Number optional

      Either 4 indicating that diagonal pixels are not considered directly adjacent for polygon membership purposes or 8 indicating they are.

    • [useFloats=false] Boolean optional

      Use floating point buffers instead of int buffers.

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

gdal.polygonizeAsync
(
  • options
  • callback=undefined
)
Promise

Creates vector polygons for all connected regions of pixels in the raster sharing a common pixel value. Each polygon is created with an attribute indicating the pixel value of that polygon. A raster mask may also be provided to determine which pixels are eligible for processing. 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:

  • options PolygonizeOptions
    • src gdal.RasterBand
    • dst gdal.Layer
    • [mask] gdal.RasterBand optional
    • pixValField Number

      The attribute field index indicating the feature attribute into which the pixel value of the polygon should be written.

    • [connectedness=4] Number optional

      Either 4 indicating that diagonal pixels are not considered directly adjacent for polygon membership purposes or 8 indicating they are.

    • [useFloats=false] Boolean optional

      Use floating point buffers instead of int buffers.

    • [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
gdal.quiet ()

Disables all output.

gdal.reprojectImage
(
  • options
)

Reprojects a dataset.

Parameters:

  • options ReprojectOptions
    • src gdal.Dataset
    • dst gdal.Dataset
    • s_srs gdal.SpatialReference
    • t_srs gdal.SpatialReference
    • [resampling] String optional

      Resampling algorithm (available options)

    • [cutline] gdal.Geometry optional

      Must be in src dataset pixel coordinates. Use CoordinateTransformation to convert between georeferenced coordinates and pixel coordinates

    • [srcBands] Number[] optional
    • [dstBands] Number[] optional
    • [srcAlphaBand] Number optional
    • [dstAlphaBand] Number optional
    • [srcNodata] Number optional
    • [dstNodata] Number optional
    • [memoryLimit] Number optional
    • [maxError] Number optional
    • [multi] Boolean optional
    • [options] Warp options (see: [reference] String[] | Object 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.

gdal.reprojectImageAsync
(
  • options
  • callback=undefined
)
Promise

Reprojects a dataset. 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:

  • options ReprojectOptions
    • src gdal.Dataset
    • dst gdal.Dataset
    • s_srs gdal.SpatialReference
    • t_srs gdal.SpatialReference
    • [resampling] String optional

      Resampling algorithm (available options)

    • [cutline] gdal.Geometry optional

      Must be in src dataset pixel coordinates. Use CoordinateTransformation to convert between georeferenced coordinates and pixel coordinates

    • [srcBands] Number[] optional
    • [dstBands] Number[] optional
    • [srcAlphaBand] Number optional
    • [dstAlphaBand] Number optional
    • [srcNodata] Number optional
    • [dstNodata] Number optional
    • [memoryLimit] Number optional
    • [maxError] Number optional
    • [multi] Boolean optional
    • [options] Warp options (see:[reference] String[] | Object 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
gdal.setPROJSearchPaths
(
  • Path
)

Set paths where proj will search it data.

Parameters:

  • Path String

    c:\ProjData

gdal.sieveFilter
(
  • options
)

Removes small raster polygons.

Parameters:

  • options SieveOptions
    • src gdal.RasterBand
    • dst gdal.RasterBand

      Output raster band. It may be the same as src band to update the source in place.

    • [mask] gdal.RasterBand optional

      All pixels in the mask band with a value other than zero will be considered suitable for inclusion in polygons.

    • threshold Number

      Raster polygons with sizes smaller than this will be merged into their largest neighbour.

    • [connectedness=4] Number optional

      Either 4 indicating that diagonal pixels are not considered directly adjacent for polygon membership purposes or 8 indicating they are.

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

gdal.sieveFilterAsync
(
  • options
  • callback=undefined
)
Promise

Removes small raster polygons. 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:

  • options SieveOptions
    • src gdal.RasterBand
    • dst gdal.RasterBand

      Output raster band. It may be the same as src band to update the source in place.

    • [mask] gdal.RasterBand optional

      All pixels in the mask band with a value other than zero will be considered suitable for inclusion in polygons.

    • threshold Number

      Raster polygons with sizes smaller than this will be merged into their largest neighbour.

    • [connectedness=4] Number optional

      Either 4 indicating that diagonal pixels are not considered directly adjacent for polygon membership purposes or 8 indicating they are.

    • [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
gdal.suggestedWarpOutput
(
  • options
)
WarpOutput

Used to determine the bounds and resolution of the output virtual file which should be large enough to include all the input image.

Parameters:

Returns:

WarpOutput:

An object containing "rasterSize" and "geoTransform" properties.

gdal.suggestedWarpOutputAsync
(
  • options
  • callback=undefined
)
Promise

Used to determine the bounds and resolution of the output virtual file which should be large enough to include all the input image. 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:

  • options WarpOptions

    Warp options

  • [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
gdal.translate
(
  • destination
  • source
  • args
  • options
)
gdal.Dataset

Library version of gdal_translate.

Parameters:

  • destination String

    destination filename

  • source gdal.Dataset

    source dataset

  • [args] String[] optional

    array of CLI options for gdal_translate

  • [options] UtilOptions optional

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

Returns:

Example:

const ds = gdal.open('input.tif') const out = gdal.translate('/vsimem/temp.tif', ds, [ '-b', '1' ])

gdal.translateAsync
(
  • destination
  • source
  • args
  • options
  • callback=undefined
)
Promise

Library version of gdal_translate. 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:

  • destination String

    destination filename

  • source gdal.Dataset

    source dataset

  • [args] String[] optional

    array of CLI options for gdal_translate

  • [options] UtilOptions optional

    additional 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

Example:

const ds = gdal.open('input.tif') const out = gdal.translate('/vsimem/temp.tif', ds, [ '-b', '1' ])

gdal.vectorTranslate
(
  • destination
  • source
  • args
  • options
)
gdal.Dataset

Library version of ogr2ogr.

Parameters:

  • destination String | gdal.Dataset

    destination

  • source gdal.Dataset

    source dataset

  • [args] String[] optional

    array of CLI options for ogr2ogr

  • [options] UtilOptions optional

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

Returns:

Example:

const ds = gdal.open('input.geojson') const out = gdal.vectorTranslate('/vsimem/temp.gpkg', [ '-of', 'GPKG' ], ds)

gdal.vectorTranslateAsync
(
  • destination
  • source
  • args
  • options
  • callback=undefined
)
Promise

Library version of ogr2ogr. 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:

  • destination String | gdal.Dataset

    destination

  • source gdal.Dataset

    source dataset

  • [args] String[] optional

    array of CLI options for ogr2ogr

  • [options] UtilOptions optional

    additional 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

Example:

const ds = gdal.open('input.geojson') const out = gdal.vectorTranslate('/vsimem/temp.gpkg', [ '-of', 'GPKG' ], ds)

gdal.verbose ()

Displays extra debugging information from GDAL.

gdal.warp
(
  • dst_path
  • dst_ds
  • src_ds
  • args
  • options
)
gdal.Dataset

Library version of gdalwarp.

Parameters:

  • dst_path String | Null

    destination path, null for an in-memory operation

  • dst_ds gdal.Dataset | Null

    destination dataset, null for a new dataset

  • src_ds gdal.Dataset[][]

    array of source datasets

  • [args] String[] optional

    array of CLI options for gdalwarp

  • [options] UtilOptions optional

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

Returns:

Example:

const ds = gdal.open('input.tif') const output = gdal.warp('/vsimem/temp.tif')

gdal.warpAsync
(
  • dst_path
  • dst_ds
  • src_ds
  • args
  • options
  • callback=undefined
)
Promise

Library version of gdalinfo. 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:

  • dst_path String | Null

    destination path, null for an in-memory operation

  • dst_ds gdal.Dataset | Null

    destination dataset, null for a new dataset

  • src_ds gdal.Dataset[][]

    array of source datasets

  • [args] String[] optional

    array of CLI options for gdalwarp

  • [options] UtilOptions optional

    additional 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

Example:

const ds = gdal.open('input.tif') const output = gdal.warp('/vsimem/temp.tif')