gdal

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 .

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


Major Objects

Classes for GDAL Major Objects

function open() lib/gdal.js

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
Parameter Type Description
path string | Buffer

Path to dataset or in-memory Buffer to open

mode string

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

drivers string | Array < string > | undefined

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

x_size number | undefined

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

y_size number | undefined

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

band_count number | undefined

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

data_type string | undefined

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

creation_options Array < string > | object | undefined

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

Throws

Error

Returns Example
var dataset = gdal.open('./data.shp');
var dataset = gdal.open(fs.readFileSync('./data.shp'));

function openAsync() lib/gdal.js

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
Parameter Type Description
path string | Buffer

Path to dataset or in-memory Buffer to open

mode string

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

drivers string | Array < string > | undefined

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

x_size number | undefined

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

y_size number | undefined

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

band_count number | undefined

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

data_type string | undefined

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

creation_options Array < string > | object | undefined

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

callback callback < Dataset >
Returns Example
var dataset = await gdal.openAsync('./data.shp');
var dataset = await gdal.openAsync(await fd.readFile('./data.shp'));
gdal.openAsync('./data.shp', (err, ds) => {...});

function openAsync() lib/gdal.js

TypeScript shorthand version with callback and no optional arguments

Parameters
Parameter Type Description
path string | Buffer

Path to dataset or in-memory Buffer to open

callback callback < Dataset >
Returns
void

class Dataset src/gdal_dataset.cpp

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

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

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

bands : DatasetBands src/gdal_dataset.cpp


description : string src/gdal_dataset.cpp


driver : Driver src/gdal_dataset.cpp


geoTransform : Array < number > | null src/gdal_dataset.cpp

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 < Array < number > | null > src/gdal_dataset.cpp

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

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

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];

layers : DatasetLayers src/gdal_dataset.cpp


rasterSize : xyz src/gdal_dataset.cpp

Raster dimensions. An object containing x and y properties.


rasterSizeAsync : Promise < xyz > src/gdal_dataset.cpp

Raster dimensions. An object containing x and y properties.

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


root : Group src/gdal_dataset.cpp


srs : SpatialReference | null src/gdal_dataset.cpp

Spatial reference associated with raster dataset.

Throws

srsAsync : Promise < SpatialReference | null > src/gdal_dataset.cpp

Spatial reference associated with raster dataset.

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

Throws

function buildOverviews() src/gdal_dataset.cpp

Builds dataset overviews.

Parameters
Parameter Type Description
resampling string

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

overviews Array < number >
bands Array < number > | undefined

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

options ProgressOptions | undefined

options

Throws

function buildOverviewsAsync() src/gdal_dataset.cpp

Builds dataset overviews.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
resampling string

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

overviews Array < number >
bands Array < number > | undefined

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

options ProgressOptions | undefined

options

callback callback < void >
Throws Returns
Promise < void >

function close() src/gdal_dataset.cpp

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.

flush()/flushAsync() ensure that, when writing, all data has been written.


function executeSQL() src/gdal_dataset.cpp

Execute an SQL statement against the data store.

Parameters
Parameter Type Description
statement string

SQL statement to execute.

spatial_filter Geometry

Geometry which represents a spatial filter.

dialect string

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.

Throws Returns

function executeSQLAsync() src/gdal_dataset.cpp

Execute an SQL statement against the data store.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
statement string

SQL statement to execute.

spatial_filter Geometry

Geometry which represents a spatial filter.

dialect string

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 callback < Layer >
Throws Returns

function flush() src/gdal_dataset.cpp

Flushes all changes to disk.

Throws

function flushAsync() src/gdal_dataset.cpp

Flushes all changes to disk.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
callback callback < void >
Throws Returns
Promise < void >

function getFileList() src/gdal_dataset.cpp

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
Array < string >

function getGCPProjection() src/gdal_dataset.cpp

Get output projection for GCPs.

Returns
string

function getGCPs() src/gdal_dataset.cpp

Fetches GCPs.

Returns
Array < any >

function getMetadata() src/gdal_dataset.cpp

Fetch metadata.

Parameters
Parameter Type Description
domain string | undefined
Returns
any

function getMetadataAsync() src/gdal_dataset.cpp

Fetch metadata.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
domain string | undefined
callback callback < void >
Returns
Promise < any >

function setGCPs() src/gdal_dataset.cpp

Sets GCPs.

Parameters
Parameter Type Description
gcps Array < object >
projection string | undefined
Throws

function setMetadata() src/gdal_dataset.cpp

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

Parameters
Parameter Type Description
metadata object | Array < string >
domain string | undefined
Returns
boolean

function setMetadataAsync() src/gdal_dataset.cpp

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

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
metadata object | Array < string >
domain string | undefined
callback callback < boolean >
Returns
Promise < boolean >

function testCapability() src/gdal_dataset.cpp

Determines if the dataset supports the indicated operation.

Parameters
Parameter Type Description
capability string

capability list

Returns
boolean


class DatasetBands src/collections/dataset_bands.cpp

An encapsulation of a Dataset raster bands.

Example
var bands = dataset.bands;
Static members

function forEach() lib/iterators.js

Iterates through all bands using a callback function. Note: GDAL band indexes start at 1, not 0.

Parameters
Parameter Type Description
callback forEachCb < RasterBand >

The callback to be called with each RasterBand

Example
dataset.bands.forEach(function(band, i) { ... });

function getEnvelope() lib/gdal.js

Returns a Envelope object for the raster bands

Returns Example
const extent = dataset.getEnvelope()
`

function Symbol.asyncIterator() : RasterBand lib/iterators.js

Iterates through all bands using an async iterator

Example
for await (const band of dataset.bands) {
}

function Symbol.iterator() : RasterBand lib/iterators.js

Iterates through all bands using an iterator

Example
for (const band of dataset.bands) {
}

Instance members

ds : Dataset src/collections/dataset_bands.cpp

Returns the parent dataset.


function count() src/collections/dataset_bands.cpp

Returns the number of bands.

Returns
number

function countAsync() src/collections/dataset_bands.cpp

Returns the number of bands.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
callback callback < number >
Returns
Promise < number >

function create() src/collections/dataset_bands.cpp

Adds a new band.

Parameters
Parameter Type Description
dataType string

Type of band ( see GDT constants )

options object | Array < string > | undefined

Creation options

Throws Returns

function createAsync() src/collections/dataset_bands.cpp

Adds a new band.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
dataType string

Type of band ( see GDT constants )

options object | Array < string > | undefined

Creation options

callback callback < RasterBand >
Throws Returns

function get() src/collections/dataset_bands.cpp

Returns the band with the given ID.

Parameters
Parameter Type Description
id number
Throws Returns

function getAsync() src/collections/dataset_bands.cpp

Returns the band with the given ID.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
id number
callback callback < RasterBand >
Throws Returns

function map() lib/default_iterators.js

Iterates through raster bands using a callback function and builds an array of the returned values.

Parameters
Parameter Type Description
callback mapCb < RasterBand , U >

The callback to be called with each RasterBand

Returns
Array < U >
Example
var result = dataset.bands.map(function(array, i) {
    return value;
});


class Driver src/gdal_driver.cpp

Format specific driver.

An instance of this class is created for each supported format, and manages information about the format.

This roughly corresponds to a file format, though some drivers may be gateways to many formats through a secondary multi-library.

Instance members

description : string src/gdal_driver.cpp


function copyFiles() src/gdal_driver.cpp

Copy the files of a dataset.

Parameters
Parameter Type Description
name_old string

New name for the dataset.

name_new string

Old name of the dataset.

Throws

function create() src/gdal_driver.cpp

Create a new dataset with this driver.

Parameters
Parameter Type Description
filename string
x_size number

raster width in pixels (ignored for vector datasets)

y_size number

raster height in pixels (ignored for vector datasets)

band_count number
data_type string

pixel data type (ignored for vector datasets) (see data types

creation_options StringOptions | undefined

An array or object containing driver-specific dataset creation options

Throws Returns

function createAsync() src/gdal_driver.cpp

Asynchronously create a new dataset with this driver.

Parameters
Parameter Type Description
filename string
x_size number

raster width in pixels (ignored for vector datasets)

y_size number

raster height in pixels (ignored for vector datasets)

band_count number
data_type string

pixel data type (ignored for vector datasets) (see data types

creation_options StringOptions | undefined

An array or object containing driver-specific dataset creation options

callback callback < Dataset >
Throws Returns

function createCopy() src/gdal_driver.cpp

Create a copy of a dataset.

Parameters
Parameter Type Description
filename string
src Dataset
options StringOptions

An array or object containing driver-specific dataset creation options

strict boolean

strict mode

jsoptions CreateOptions | undefined

additional options

Throws Returns

function createCopyAsync() src/gdal_driver.cpp

Asynchronously create a copy of a dataset.

Parameters
Parameter Type Description
filename string
src Dataset
options StringOptions

An array or object containing driver-specific dataset creation options

strict boolean

strict mode

jsoptions CreateOptions | undefined

additional options

callback callback < Dataset >
Throws Returns

function deleteDataset() src/gdal_driver.cpp

Parameters
Parameter Type Description
filename string
Throws

function getMetadata() src/gdal_driver.cpp

Returns metadata about the driver.

Parameters
Parameter Type Description
domain string | undefined
Throws Returns
any

function open() src/gdal_driver.cpp

Opens a dataset.

Parameters
Parameter Type Description
path string
mode string

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

options StringOptions | undefined

Driver-specific open options

Throws Returns

function openAsync() src/gdal_driver.cpp

Opens a dataset.

Parameters
Parameter Type Description
path string
mode string

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

options StringOptions | undefined

Driver-specific open options

callback callback < Dataset >
Throws Returns

function rename() src/gdal_driver.cpp

Renames the dataset.

Parameters
Parameter Type Description
new_name string

New name for the dataset.

old_name string

Old name of the dataset.

Throws


class GDALDrivers src/collections/gdal_drivers.cpp

An collection of all Driver registered with GDAL.

Instance members

function count() src/collections/gdal_drivers.cpp

Returns the number of drivers registered with GDAL.

Returns
number

function forEach() lib/default_iterators.js

Iterates through all drivers using a callback function.

Parameters
Parameter Type Description
callback forEachCb < Driver >

The callback to be called with each Driver

Example
gdal.drivers.forEach(function(array, i) { ... });

function get() src/collections/gdal_drivers.cpp

Returns a driver with the specified name.

Note: Prior to GDAL2.x there is a separate driver for vector VRTs and raster VRTs. Use "VRT:vector" to fetch the vector VRT driver and "VRT:raster" to fetch the raster VRT driver.

Parameters
Parameter Type Description
index number | string

0-based index or driver name

Throws Returns

function getNames() src/collections/gdal_drivers.cpp

Returns an array with the names of all the drivers registered with GDAL.

Returns
Array < string >

function map() lib/default_iterators.js

Iterates through drivers using a callback function and builds an array of the returned values.

Parameters
Parameter Type Description
callback mapCb < Driver , U >

The callback to be called with each Driver

Returns
Array < U >
Example
var result = gdal.drivers.map(function(array, i) {
    return value;
});

function prototype() : Driver lib/default_iterators.js

Iterates through all drivers using an iterator

Example
for (const array of gdal.drivers) {
}


class RasterBand src/gdal_rasterband.cpp

A single raster band (or channel).

Instance members

blockSize : xyz src/gdal_rasterband.cpp

Size object containing "x" and "y" properties.


blockSizeAsync : Promise < xyz > src/gdal_rasterband.cpp

Size object containing "x" and "y" properties.

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


categoryNames : Array < string > src/gdal_rasterband.cpp

List of list of category names for this raster.


categoryNamesAsync : Promise < Array < string > > src/gdal_rasterband.cpp

List of list of category names for this raster.

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


colorInterpretation : string | null src/gdal_rasterband.cpp

Color interpretation mode ( see GCI constants )


colorInterpretationAsync : Promise < string | null > src/gdal_rasterband.cpp

Color interpretation mode ( see GCI constants )

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


colorTable : ColorTable | null src/gdal_rasterband.cpp

Color table ( see ColorTable )


colorTableAsync : Promise < ColorTable | null > src/gdal_rasterband.cpp

Color table ( see ColorTable )

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


dataType : string | null src/gdal_rasterband.cpp

Pixel data type ( see GDT constants used for this band.


dataTypeAsync : Promise < string | null > src/gdal_rasterband.cpp

Pixel data type ( see GDT constants used for this band.

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


description : string src/gdal_rasterband.cpp

Name of of band.


descriptionAsync : Promise < string > src/gdal_rasterband.cpp

Name of of band.

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


ds : Dataset src/gdal_rasterband.cpp


hasArbitraryOverviews : boolean src/gdal_rasterband.cpp

An indicator if the underlying datastore can compute arbitrary overviews efficiently, such as is the case with OGDI over a network. Datastores with arbitrary overviews don't generally have any fixed overviews, but GDAL's RasterIO() method can be used in downsampling mode to get overview data efficiently.


hasArbitraryOverviewsAsync : Promise < boolean > src/gdal_rasterband.cpp

An indicator if the underlying datastore can compute arbitrary overviews efficiently, such as is the case with OGDI over a network. Datastores with arbitrary overviews don't generally have any fixed overviews, but GDAL's RasterIO() method can be used in downsampling mode to get overview data efficiently.

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


id : number | null src/gdal_rasterband.cpp


idAsync : Promise < number | null > src/gdal_rasterband.cpp

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


maximum : number | null src/gdal_rasterband.cpp

Maximum value for this band.


maximumAsync : Promise < number | null > src/gdal_rasterband.cpp

Maximum value for this band.

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


minimum : number | null src/gdal_rasterband.cpp

Minimum value for this band.


minimumAsync : Promise < number | null > src/gdal_rasterband.cpp

Minimum value for this band.

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


noDataValue : number | null src/gdal_rasterband.cpp

No data value for this band.


noDataValueAsync : Promise < number | null > src/gdal_rasterband.cpp

No data value for this band.

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


offset : number | null src/gdal_rasterband.cpp

Raster value offset.


offsetAsync : Promise < number | null > src/gdal_rasterband.cpp

Raster value offset.

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


overviews : RasterBandOverviews src/gdal_rasterband.cpp


pixels : RasterBandPixels src/gdal_rasterband.cpp


readOnly : boolean src/gdal_rasterband.cpp

Indicates if the band is read-only.


readOnlyAsync : Promise < boolean > src/gdal_rasterband.cpp

Indicates if the band is read-only.

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


scale : number | null src/gdal_rasterband.cpp

Raster value scale.


scaleAsync : Promise < number | null > src/gdal_rasterband.cpp

Raster value scale.

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


size : xyz src/gdal_rasterband.cpp

Size object containing "x" and "y" properties.


sizeAsync : Promise < xyz > src/gdal_rasterband.cpp

Size object containing "x" and "y" properties.

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


unitType : string | null src/gdal_rasterband.cpp

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.


unitTypeAsync : Promise < string | null > src/gdal_rasterband.cpp

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.

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


function asMDArray() src/gdal_rasterband.cpp

Return a view of this raster band as a 2D multidimensional GDALMDArray.

The band must be linked to a GDALDataset.

If the dataset has a geotransform attached, the X and Y dimensions of the returned array will have an associated indexing variable.

Requires GDAL>=3.3 with MDArray support, won't be defined otherwise

Throws Returns

function computeStatistics() src/gdal_rasterband.cpp

Computes image statistics.

Returns the minimum, maximum, mean and standard deviation of all pixel values in this band. If approximate statistics are sufficient, the allow_approximation argument can be set to true in which case overviews, or a subset of image tiles may be used in computing the statistics.

Parameters
Parameter Type Description
allow_approximation boolean

If true statistics may be computed based on overviews or a subset of all tiles.

Throws Returns
stats

Statistics containing "min" , "max" , "mean" , "std_dev" properties.


function computeStatisticsAsync() src/gdal_rasterband.cpp

Computes image statistics. {{async}}

Returns the minimum, maximum, mean and standard deviation of all pixel values in this band. If approximate statistics are sufficient, the allow_approximation argument can be set to true in which case overviews, or a subset of image tiles may be used in computing the statistics.

Parameters
Parameter Type Description
allow_approximation boolean

If true statistics may be computed based on overviews or a subset of all tiles.

callback callback < stats >
Throws Returns
Promise < stats >

Statistics containing "min" , "max" , "mean" , "std_dev" properties.


function createMaskBand() src/gdal_rasterband.cpp

Adds a mask band to the current band.

Parameters
Parameter Type Description
flags number

Mask flags

Throws

function fill() src/gdal_rasterband.cpp

Fill this band with a constant value.

Parameters
Parameter Type Description
real_value number
imaginary_value number | undefined
Throws

function fillAsync() src/gdal_rasterband.cpp

Fill this band with a constant value.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
real_value number
imaginary_value number | undefined
callback callback < void >
Throws Returns
Promise < void >

function flush() src/gdal_rasterband.cpp

Saves changes to disk.


function flushAsync() src/gdal_rasterband.cpp

Saves changes to disk.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
callback callback < void >
Returns
Promise < void >

function getMaskBand() src/gdal_rasterband.cpp

Return the mask band associated with the band.

Returns

function getMaskFlags() src/gdal_rasterband.cpp

Return the status flags of the mask band associated with the band.

The result will be a bitwise OR-ed set of status flags with the following available definitions that may be extended in the future:

Returns
number

Mask flags


function getMetadata() src/gdal_rasterband.cpp

Returns band metadata.

Parameters
Parameter Type Description
domain string | undefined
Returns
any

function getMetadataAsync() src/gdal_rasterband.cpp

Returns band metadata.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
domain string | undefined
callback callback < any >
Returns
Promise < any >

function getStatistics() src/gdal_rasterband.cpp

Fetch image statistics.

Returns the minimum, maximum, mean and standard deviation of all pixel values in this band. If approximate statistics are sufficient, the allow_approximation argument can be set to true in which case overviews, or a subset of image tiles may be used in computing the statistics.

Parameters
Parameter Type Description
allow_approximation boolean

If true statistics may be computed based on overviews or a subset of all tiles.

force boolean

If false statistics will only be returned if it can be done without rescanning the image.

Throws Returns
object

Statistics containing "min" , "max" , "mean" , "std_dev" properties.


function setMetadata() src/gdal_rasterband.cpp

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

Parameters
Parameter Type Description
metadata object | Array < string >
domain string | undefined
Returns
boolean

function setMetadataAsync() src/gdal_rasterband.cpp

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

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
metadata object | Array < string >
domain string | undefined
callback callback < boolean >
Returns
Promise < boolean >

function setStatistics() src/gdal_rasterband.cpp

Set statistics on the band. This method can be used to store min/max/mean/standard deviation statistics.

Parameters
Parameter Type Description
min number
max number
mean number
std_dev number
Throws


class RasterBandPixels src/collections/rasterband_pixels.cpp

A representation of a RasterBand 's pixels.

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

Example
const n = 16*16;
const data = new Float32Array(new ArrayBuffer(n*4));
//read data into the existing array
band.pixels.read(0,0,16,16,data);
Static members

typedef ReadOptions : object src/collections/rasterband_pixels.cpp

Properties
Property Type Description
buffer_width number | undefined
buffer_height number | undefined
type string | undefined
data_type string | undefined
pixel_space number | undefined
line_space number | undefined
resampling string | undefined
progress_cb ProgressCb | undefined
offset number | undefined

typedef TypedArray : Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array src/collections/rasterband_pixels.cpp


typedef WriteOptions : object src/collections/rasterband_pixels.cpp

Properties
Property Type Description
buffer_width number | undefined
buffer_height number | undefined
pixel_space number | undefined
line_space number | undefined
progress_cb ProgressCb | undefined
offset number | undefined

Instance members

band : RasterBand src/collections/rasterband_pixels.cpp

Returns the parent raster band.


function clampBlock() src/collections/rasterband_pixels.cpp

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
Parameter Type Description
x number
y number
Throws Returns
xyz

A size object.


function clampBlockAsync() src/collections/rasterband_pixels.cpp

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.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
x number
y number
callback callback < xyz >
Throws Returns
Promise < xyz >

A size object.


function createReadStream() lib/readable.js

create a Readable stream from a raster band

Parameters
Parameter Type Description
options RasterReadableOptions | undefined
Returns

function createWriteStream() lib/writable.js

create a Writable stream from a raster band

Parameters
Parameter Type Description
options RasterWritableOptions | undefined
Returns

function get() src/collections/rasterband_pixels.cpp

Returns the value at the x, y coordinate.

Parameters
Parameter Type Description
x number
y number
Throws Returns
number

function getAsync() src/collections/rasterband_pixels.cpp

Returns the value at the x, y coordinate.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
x number
y number
callback callback < number >
Returns
Promise < number >

function read() src/collections/rasterband_pixels.cpp

Reads a region of pixels.

Parameters
Parameter Type Description
x number
y number
width number
height number
data TypedArray | undefined

The TypedArray to put the data in. A new array is created if not given.

options ReadOptions | undefined
Throws Returns
TypedArray

A TypedArray of values.


function readAsync() src/collections/rasterband_pixels.cpp

Asynchronously reads a region of pixels.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
x number
y number
width number

the width

height number
data TypedArray | undefined

The TypedArray to put the data in. A new array is created if not given.

options ReadOptions | undefined
callback callback < TypedArray >
Returns
Promise < TypedArray >

A TypedArray of values.


function readBlock() src/collections/rasterband_pixels.cpp

Reads a block of pixels.

Parameters
Parameter Type Description
x number
y number
data TypedArray | undefined

The TypedArray to put the data in. A new array is created if not given.

Throws Returns
TypedArray

A TypedArray of values.


function readBlockAsync() src/collections/rasterband_pixels.cpp

Reads a block of pixels.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
x number
y number
data TypedArray | undefined

The TypedArray to put the data in. A new array is created if not given.

callback callback < TypedArray >
Throws Returns
Promise < TypedArray >

A TypedArray of values.


function set() src/collections/rasterband_pixels.cpp

Sets the value at the x, y coordinate.

Parameters
Parameter Type Description
x number
y number
value number

function setAsync() src/collections/rasterband_pixels.cpp

Sets the value at the x, y coordinate.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
x number
y number
value number
callback callback < void >
Returns
Promise < void >

function write() src/collections/rasterband_pixels.cpp

Writes a region of pixels.

Parameters
Parameter Type Description
x number
y number
width number
height number
data TypedArray | undefined

The TypedArray to write to the band.

options WriteOptions | undefined
Throws

function writeAsync() src/collections/rasterband_pixels.cpp

Asynchronously writes a region of pixels.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
x number
y number
width number
height number
data TypedArray | undefined

The TypedArray to write to the band.

options WriteOptions | undefined
callback callback < void >
Returns
Promise < void >

function writeBlock() src/collections/rasterband_pixels.cpp

Writes a block of pixels.

Parameters
Parameter Type Description
x number
y number
data TypedArray

The TypedArray of values to write to the band.

Throws

function writeBlockAsync() src/collections/rasterband_pixels.cpp

Writes a block of pixels.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
x number
y number
data TypedArray

The TypedArray of values to write to the band.

callback callback < void >
Throws Returns
Promise < void >


class RasterBandOverviews src/collections/rasterband_overviews.cpp

An encapsulation of a RasterBand overview functionality.

Instance members

function asyncIterator() : RasterBand lib/default_iterators.js

Iterates through all overviews using an async iterator

Example
for await (const array of band.overviews) {
}

function count() src/collections/rasterband_overviews.cpp

Returns the number of overviews.

Returns
number

function countAsync() src/collections/rasterband_overviews.cpp

Returns the number of overviews.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
callback callback < number >
Returns
Promise < number >

function forEach() lib/default_iterators.js

Iterates through all overviews using a callback function.

Parameters
Parameter Type Description
callback forEachCb < RasterBand >

The callback to be called with each RasterBand

Example
band.overviews.forEach(function(array, i) { ... });

function get() src/collections/rasterband_overviews.cpp

Fetches the overview at the provided index.

Parameters
Parameter Type Description
index number

0-based index

Throws Returns

function getAsync() src/collections/rasterband_overviews.cpp

Fetches the overview at the provided index.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
index number

0-based index

callback callback < RasterBand >
Throws Returns

function getBySampleCount() src/collections/rasterband_overviews.cpp

Fetch best sampling overview.

Returns the most reduced overview of the given band that still satisfies the desired number of samples. This function can be used with zero as the number of desired samples to fetch the most reduced overview. The same band as was passed in will be returned if it has not overviews, or if none of the overviews have enough samples.

Parameters
Parameter Type Description
samples number
Returns

function getBySampleCountAsync() src/collections/rasterband_overviews.cpp

Fetch best sampling overview.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
samples number
callback callback < RasterBand >
Returns

function map() lib/default_iterators.js

Iterates through overviews using a callback function and builds an array of the returned values.

Parameters
Parameter Type Description
callback mapCb < RasterBand , U >

The callback to be called with each RasterBand

Returns
Array < U >
Example
var result = band.overviews.map(function(array, i) {
    return value;
});

function prototype() : RasterBand lib/default_iterators.js

Iterates through all overviews using an iterator

Example
for (const array of band.overviews) {
}


class ColorTable src/collections/colortable.cpp

An encapsulation of a RasterBand color table.

Parameters
Parameter Type Description
interpretation string

palette interpretation

Example
var colorTable = band.colorTable;

band.colorTable = new gdal.ColorTable(gdal.GPI_RGB);
Static members

typedef Color : object src/collections/colortable.cpp

Properties
Property Type Description
c1 number
c2 number
c3 number
c4 number

Instance members

band : RasterBand | src/collections/colortable.cpp

Returns the parent band.


interpretation : string src/collections/colortable.cpp

Color interpretation of the palette.


function clone() src/collections/colortable.cpp

Clones the instance. The newly created ColorTable is not owned by any RasterBand.

Returns

function count() src/collections/colortable.cpp

Returns the number of color entries.

Returns
number

function forEach() lib/default_iterators.js

Iterates through all color entries using a callback function.

Parameters
Parameter Type Description
callback forEachCb < Color >

The callback to be called with each Color

Example
band.colorTable.forEach(function(array, i) { ... });

function get() src/collections/colortable.cpp

Returns the color with the given ID.

Parameters
Parameter Type Description
index number
Throws Returns

function isSame() src/collections/colortable.cpp

Compares two ColorTable objects for equality.

Parameters
Parameter Type Description
other ColorTable
Throws Returns
boolean

function map() lib/default_iterators.js

Iterates through color entries using a callback function and builds an array of the returned values.

Parameters
Parameter Type Description
callback mapCb < Color , U >

The callback to be called with each Color

Returns
Array < U >
Example
var result = band.colorTable.map(function(array, i) {
    return value;
});

function prototype() : Color lib/default_iterators.js

Iterates through all color entries using an iterator

Example
for (const array of band.colorTable) {
}

function ramp() src/collections/colortable.cpp

Creates a color ramp from one color entry to another.

Parameters
Parameter Type Description
start_index number
start_color Color
end_index number
end_color Color
Throws Returns
number

total number of color entries


function set() src/collections/colortable.cpp

Sets the color entry with the given ID.

Parameters
Parameter Type Description
index number
color Color
Throws Returns
void


class Layer src/gdal_layer.cpp

A representation of a layer of simple vector features, with access methods.

Instance members

ds : Dataset src/gdal_layer.cpp


features : LayerFeatures src/gdal_layer.cpp


fidColumn : string src/gdal_layer.cpp


fields : LayerFields src/gdal_layer.cpp


geomColumn : string src/gdal_layer.cpp


geomType : number src/gdal_layer.cpp


name : string src/gdal_layer.cpp


srs : SpatialReference src/gdal_layer.cpp


function flush() src/gdal_layer.cpp

Flush pending changes to disk.

Throws

function flushAsync() src/gdal_layer.cpp

Flush pending changes to disk.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
callback callback < void >
Throws Returns
Promise < void >

function getExtent() src/gdal_layer.cpp

Fetch the extent of this layer.

Parameters
Parameter Type Description
force boolean
Throws Returns
Envelope

Bounding envelope


function getSpatialFilter() src/gdal_layer.cpp

This method returns the current spatial filter for this layer.

Throws Returns

function setAttributeFilter() src/gdal_layer.cpp

Sets the attribute query string to be used when fetching features via the layer.features.next() method. Only features for which the query evaluates as true will be returned.

The query string should be in the format of an SQL WHERE clause. For instance "population > 1000000 and population < 5000000" where population is an attribute in the layer. The query format is normally a restricted form of SQL WHERE clause as described in the "WHERE" section of the OGR SQL tutorial . In some cases (RDBMS backed drivers) the native capabilities of the database may be used to interprete the WHERE clause in which case the capabilities will be broader than those of OGR SQL.

Parameters
Parameter Type Description
filter string | null
Throws Example
layer.setAttributeFilter('population > 1000000 and population < 5000000');

function setSpatialFilter() src/gdal_layer.cpp

This method sets the geometry to be used as a spatial filter when fetching features via the layer.features.next() method. Only features that geometrically intersect the filter geometry will be returned.

Alernatively you can pass it envelope bounds as individual arguments.

Parameters
Parameter Type Description
filter Geometry | null
Throws Example
layer.setSpatialFilter(geometry);

function setSpatialFilter() src/gdal_layer.cpp

This method sets the geometry to be used as a spatial filter when fetching features via the layer.features.next() method. Only features that geometrically intersect the filter geometry will be returned.

Alernatively you can pass it envelope bounds as individual arguments.

Parameters
Parameter Type Description
minxX number
minyY number
maxX number
maxY number
Throws Example
layer.setSpatialFilter(minX, minY, maxX, maxY);

function testCapability() src/gdal_layer.cpp

Determines if the dataset supports the indicated operation.

Parameters
Parameter Type Description
capability string

(see capability list

Returns
boolean


class DatasetLayers src/collections/dataset_layers.cpp

An encapsulation of a Dataset vector layers.

Example
var layers = dataset.layers;
Instance members

ds : Dataset src/collections/dataset_layers.cpp

Returns the parent dataset.


function asyncIterator() : Layer lib/default_iterators.js

Iterates through all layers using an async iterator

Example
for await (const array of dataset.layers) {
}

function copy() src/collections/dataset_layers.cpp

Copies a layer.

Parameters
Parameter Type Description
src_lyr_name Layer
dst_lyr_name string
options object | Array < string >

layer creation options

Returns

function copyAsync() src/collections/dataset_layers.cpp

Copies a layer.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
src_lyr_name Layer
dst_lyr_name string
options object | Array < string >

layer creation options

callback callback < Layer >
Returns

function count() src/collections/dataset_layers.cpp

Returns the number of layers.

Returns
number

function countAsync() src/collections/dataset_layers.cpp

Returns the number of layers.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
callback callback < number >
Returns
Promise < number >

function create() src/collections/dataset_layers.cpp

Adds a new layer.

Parameters
Parameter Type Description
name string

Layer name

srs SpatialReference | null

Layer projection

geomType number | Function | null

Geometry type or constructor ( see geometry types )

creation_options Array < string > | object | undefined

driver-specific layer creation options

Throws Returns Example
dataset.layers.create('layername', null, gdal.Point);

function createAsync() src/collections/dataset_layers.cpp

Adds a new layer.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
name string

Layer name

srs SpatialReference | null

Layer projection

geomType number | Function | null

Geometry type or constructor ( see geometry types )

creation_options Array < string > | object | undefined

driver-specific layer creation options

callback callback < Layer >
Throws Returns Example
await dataset.layers.createAsync('layername', null, gdal.Point);
dataset.layers.createAsync('layername', null, gdal.Point, (e, r) => console.log(e, r));

function forEach() lib/default_iterators.js

Iterates through all layers using a callback function.

Parameters
Parameter Type Description
callback forEachCb < Layer >

The callback to be called with each Layer

Example
dataset.layers.forEach(function(array, i) { ... });

function get() src/collections/dataset_layers.cpp

Returns the layer with the given name or identifier.

Parameters
Parameter Type Description
key string | number

Layer name or ID.

Throws Returns

function getAsync() src/collections/dataset_layers.cpp

Returns the layer with the given name or identifier.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
key string | number

Layer name or ID.

callback callback < Layer >
Throws Returns

function map() lib/default_iterators.js

Iterates through layers using a callback function and builds an array of the returned values.

Parameters
Parameter Type Description
callback mapCb < Layer , U >

The callback to be called with each Layer

Returns
Array < U >
Example
var result = dataset.layers.map(function(array, i) {
    return value;
});

function prototype() : Layer lib/default_iterators.js

Iterates through all layers using an iterator

Example
for (const array of dataset.layers) {
}

function remove() src/collections/dataset_layers.cpp

Removes a layer.

Parameters
Parameter Type Description
index number
Throws

function removeAsync() src/collections/dataset_layers.cpp

Removes a layer.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
index number
callback callback < void >
Throws Returns
Promise < void >


class SpatialReference src/gdal_spatial_reference.cpp

This class respresents a OpenGIS Spatial Reference System, and contains methods for converting between this object organization and well known text (WKT) format.

Parameters
Parameter Type Description
wkt string | undefined
Instance members

function autoIdentifyEPSG() src/gdal_spatial_reference.cpp

Set EPSG authority info if possible.

Throws

function clone() src/gdal_spatial_reference.cpp

Clones the spatial reference.

Returns

function cloneGeogCS() src/gdal_spatial_reference.cpp

Make a duplicate of the GEOGCS node of this OGRSpatialReference object.

Returns

function EPSGTreatsAsLatLong() src/gdal_spatial_reference.cpp

This method returns true if EPSG feels this geographic coordinate system should be treated as having lat/long coordinate ordering.

Currently this returns true for all geographic coordinate systems with an EPSG code set, and AXIS values set defining it as lat, long. Note that coordinate systems with an EPSG code and no axis settings will be assumed to not be lat/long.

false will be returned for all coordinate systems that are not geographic, or that do not have an EPSG code set.

Returns
boolean

function EPSGTreatsAsNorthingEasting() src/gdal_spatial_reference.cpp

This method returns true if EPSG feels this projected coordinate system should be treated as having northing/easting coordinate ordering.

Returns
boolean

function fromCRSURL() src/gdal_spatial_reference.cpp

Initialize from OGC URL.

The OGC URL should be prefixed with " http://opengis.net/def/crs " per best practice paper 11-135. Currently EPSG and OGC authority values are supported, including OGC auto codes, but not including CRS1 or CRS88 (NAVD88).

Parameters
Parameter Type Description
input string
Throws Returns

function fromCRSURLAsync() src/gdal_spatial_reference.cpp

Initialize from OGC URL.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
input string
callback callback < SpatialReference >
Throws Returns

function fromEPSG() src/gdal_spatial_reference.cpp

Initialize from EPSG GCS or PCS code.

Parameters
Parameter Type Description
input number
Throws Returns Example
var ref = gdal.SpatialReference.fromEPSGA(4326);

function fromEPSGA() src/gdal_spatial_reference.cpp

Initialize from EPSG GCS or PCS code.

This method is similar to fromEPSG() except that EPSG preferred axis ordering be applied for geographic and projected coordinate systems. EPSG normally defines geographic coordinate systems to use lat/long, and also there are also a few projected coordinate systems that use northing/easting order contrary to typical GIS use).

Parameters
Parameter Type Description
input number
Throws Returns Example
var ref = gdal.SpatialReference.fromEPSGA(26910);

function fromESRI() src/gdal_spatial_reference.cpp

Import coordinate system from ESRI .prj format(s).

This function will read the text loaded from an ESRI .prj file, and translate it into an OGRSpatialReference definition. This should support many (but by no means all) old style (Arc/Info 7.x) .prj files, as well as the newer pseudo-OGC WKT .prj files. Note that new style .prj files are in OGC WKT format, but require some manipulation to correct datum names, and units on some projection parameters. This is addressed within importFromESRI() by an automatical call to morphFromESRI().

Currently only GEOGRAPHIC, UTM, STATEPLANE, GREATBRITIAN_GRID, ALBERS, EQUIDISTANT_CONIC, TRANSVERSE (mercator), POLAR, MERCATOR and POLYCONIC projections are supported from old style files.

Parameters
Parameter Type Description
input object | Array < string >
Throws Returns

function fromMICoordSys() src/gdal_spatial_reference.cpp

Initialize from a Mapinfo style CoordSys definition.

Parameters
Parameter Type Description
input string
Throws Returns

function fromProj4() src/gdal_spatial_reference.cpp

Creates a spatial reference from a Proj.4 string.

Parameters
Parameter Type Description
input string
Throws Returns

function fromURL() src/gdal_spatial_reference.cpp

Initialize spatial reference from a URL.

This method will download the spatial reference from the given URL.

Parameters
Parameter Type Description
url string
Throws Returns

function fromURLAsync() src/gdal_spatial_reference.cpp

Initialize spatial reference from a URL. {{async}}

This method will download the spatial reference from the given URL.

Parameters
Parameter Type Description
url string
callback callback < SpatialReference >
Throws Returns

function fromURN() src/gdal_spatial_reference.cpp

Initialize from OGC URN.

The OGC URN should be prefixed with "urn:ogc:def:crs:" per recommendation paper 06-023r1. Currently EPSG and OGC authority values are supported, including OGC auto codes, but not including CRS1 or CRS88 (NAVD88).

Parameters
Parameter Type Description
input string
Throws Returns

function fromUserInput() src/gdal_spatial_reference.cpp

Initialize from an arbitrary spatial reference string.

This method will examine the provided input, and try to deduce the format, and then use it to initialize the spatial reference system.

Parameters
Parameter Type Description
input string
Throws Returns

function fromUserInputAsync() src/gdal_spatial_reference.cpp

Initialize from an arbitrary spatial reference string.

This method will examine the provided input, and try to deduce the format, and then use it to initialize the spatial reference system.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
input string
callback callback < SpatialReference >
Throws Returns

function fromWKT() src/gdal_spatial_reference.cpp

Creates a spatial reference from a WKT string.

Parameters
Parameter Type Description
wkt string
Throws Returns

function fromWMSAUTO() src/gdal_spatial_reference.cpp

Creates a spatial reference from a WMSAUTO string.

Note that the WMS 1.3 specification does not include the units code, while apparently earlier specs do. GDAL tries to guess around this.

Parameters
Parameter Type Description
input string
Throws Returns Example
var wms = 'AUTO:42001,99,8888';
var ref = gdal.SpatialReference.fromWMSAUTO(wms);

function fromXML() src/gdal_spatial_reference.cpp

Import coordinate system from XML format (GML only currently).

Parameters
Parameter Type Description
input string
Throws Returns

function getAngularUnits() src/gdal_spatial_reference.cpp

Fetch angular geographic coordinate system units.

Returns
units

An object containing value and unit properties.


function getAttrValue() src/gdal_spatial_reference.cpp

Fetch indicated attribute of named node.

Parameters
Parameter Type Description
node_name string
attr_index number
Returns
string

function getAuthorityCode() src/gdal_spatial_reference.cpp

Get the authority code for a node.

Parameters
Parameter Type Description
target_key string | null | undefined

The partial or complete path to the node to get an authority from. ie. "PROJCS" , "GEOGCS" , " GEOGCS|UNIT" or null to search for an authority node on the root element.

Returns
string

function getAuthorityName() src/gdal_spatial_reference.cpp

Get the authority name for a node. The most common authority is "EPSG".

Parameters
Parameter Type Description
target_key string | null | undefined

The partial or complete path to the node to get an authority from. ie. "PROJCS" , "GEOGCS" , " GEOGCS|UNIT" or null to search for an authority node on the root element.

Returns
string

function getLinearUnits() src/gdal_spatial_reference.cpp

Fetch linear geographic coordinate system units.

Returns
units

An object containing value and unit properties.


function isCompound() src/gdal_spatial_reference.cpp

Check if compound coordinate system.

Returns
boolean

function isGeocentric() src/gdal_spatial_reference.cpp

Check if geocentric coordinate system.

Returns
boolean

function isGeographic() src/gdal_spatial_reference.cpp

Check if geographic coordinate system.

Returns
boolean

function isLocal() src/gdal_spatial_reference.cpp

Check if local coordinate system.

Returns
boolean

function isProjected() src/gdal_spatial_reference.cpp

Check if projected coordinate system.

Returns
boolean

function isSame() src/gdal_spatial_reference.cpp

Do these two spatial references describe the same system?

Parameters
Parameter Type Description
srs SpatialReference
Returns
boolean

function isSameGeogCS() src/gdal_spatial_reference.cpp

Do the GeogCS'es match?

Parameters
Parameter Type Description
srs SpatialReference
Returns
boolean

function isSameVertCS() src/gdal_spatial_reference.cpp

Do the VertCS'es match?

Parameters
Parameter Type Description
srs SpatialReference
Returns
boolean

function isVertical() src/gdal_spatial_reference.cpp

Check if vertical coordinate system.

Returns
boolean

function morphFromESRI() src/gdal_spatial_reference.cpp

Convert in place from ESRI WKT format.

Throws

function morphToESRI() src/gdal_spatial_reference.cpp

Convert in place to ESRI WKT format.

Throws

function setWellKnownGeogCS() src/gdal_spatial_reference.cpp

Set a GeogCS based on well known name.

Parameters
Parameter Type Description
name string

function toPrettyWKT() src/gdal_spatial_reference.cpp

Convert this SRS into a a nicely formatted WKT string for display to a person.

Parameters
Parameter Type Description
simplify boolean
Throws Returns
string

function toProj4() src/gdal_spatial_reference.cpp

Export coordinate system in PROJ.4 format.

Throws Returns
string

function toWKT() src/gdal_spatial_reference.cpp

Convert this SRS into WKT format.

Throws Returns
string

function toXML() src/gdal_spatial_reference.cpp

Export coordinate system in XML format.

Throws Returns
string

function validate() src/gdal_spatial_reference.cpp

Validate SRS tokens.

This method attempts to verify that the spatial reference system is well formed, and consists of known tokens. The validation is not comprehensive.

Returns
string | null

"corrupt" , '"unsupported"', null (if fine)



class CoordinateTransformation src/gdal_coordinate_transformation.cpp

Object for transforming between coordinate systems.

Parameters
Parameter Type Description
source SpatialReference
target SpatialReference | Dataset

If a raster Dataset, the conversion will represent a conversion to pixel coordinates.

Throws Instance members

function transformPoint() src/gdal_coordinate_transformation.cpp

Transform point from source to destination space.

Parameters
Parameter Type Description
x number
y number
z number | undefined
Returns
xyz

A regular object containing x , y , z properties.

Example
pt = transform.transformPoint(0, 0, 0);

function transformPoint() src/gdal_coordinate_transformation.cpp

Transform point from source to destination space.

Parameters
Parameter Type Description
point xyz
Returns
xyz

A regular object containing x , y , z properties.

Example
pt = transform.transformPoint({x: 0, y: 0, z: 0});



Features

Classes for working with vector features

class LayerFields src/collections/layer_fields.cpp

Static members

function fromJSON() lib/gdal.js

Creates a LayerFields instance from an object of keys and values.

Parameters
Parameter Type Description
object object
approx_ok boolean

function fromObject() lib/gdal.js

Creates a LayerFields instance from an object of keys and values.

Parameters
Parameter Type Description
object Record < string , any >
approx_ok boolean

Instance members

layer : Layer src/collections/layer_fields.cpp

Returns the parent layer.


function add() src/collections/layer_fields.cpp

Adds field(s).

Parameters
Parameter Type Description
defs FieldDefn | Array < FieldDefn >

A field definition, or array of field definitions.

approx boolean
Throws

function asyncIterator() : FieldDefn lib/default_iterators.js

Iterates through all field definitions using an async iterator

Example
for await (const array of layer.fields) {
}

function count() src/collections/layer_fields.cpp

Returns the number of fields.

Returns
number

function forEach() lib/default_iterators.js

Iterates through all field definitions using a callback function.

Parameters
Parameter Type Description
callback forEachCb < FieldDefn >

The callback to be called with each FieldDefn

Example
layer.fields.forEach(function(array, i) { ... });

function get() src/collections/layer_fields.cpp

Returns a field definition.

Parameters
Parameter Type Description
field string | number

Field name or index (0-based)

Throws Returns

function getNames() src/collections/layer_fields.cpp

Returns a list of field names.

Throws Returns
Array < string >

List of strings.


function indexOf() src/collections/layer_fields.cpp

Find the index of field in the layer.

Parameters
Parameter Type Description
field string
Returns
number

Field index, or -1 if the field doesn't exist


function map() lib/default_iterators.js

Iterates through field definitions using a callback function and builds an array of the returned values.

Parameters
Parameter Type Description
callback mapCb < FieldDefn , U >

The callback to be called with each FieldDefn

Returns
Array < U >
Example
var result = layer.fields.map(function(array, i) {
    return value;
});

function prototype() : FieldDefn lib/default_iterators.js

Iterates through all field definitions using an iterator

Example
for (const array of layer.fields) {
}

function remove() src/collections/layer_fields.cpp

Removes a field.

Parameters
Parameter Type Description
field string | number

Field name or index (0-based)

Throws

function reorder() src/collections/layer_fields.cpp

Reorders fields.

Parameters
Parameter Type Description
map Array < number >

An array of new indexes (integers)

Throws Example
// reverse field order
layer.fields.reorder([2,1,0]);


class LayerFeatures src/collections/layer_features.cpp

An encapsulation of a Layer features.

Static members

function forEach() lib/iterators.js

Iterates through all features using a callback function.

Parameters
Parameter Type Description
callback forEachCb < Feature >

The callback to be called with each Feature

Example
layer.features.forEach(function(feature, i) { ... });

function Symbol.asyncIterator() : Feature lib/iterators.js

Iterates through all features using an async iterator

Example
for await (const feature of layer.features) {
}

function Symbol.iterator() : Feature lib/iterators.js

Iterates through all features using an iterator

Example
for (const feature of layer.features) {
}

Instance members

layer : Layer src/collections/layer_features.cpp

Returns the parent layer.


function add() src/collections/layer_features.cpp

Adds a feature to the layer. The feature should be created using the current layer as the definition.

Parameters
Parameter Type Description
feature Feature
Throws Example
var feature = new gdal.Feature(layer);
feature.setGeometry(new gdal.Point(0, 1));
feature.fields.set('name', 'somestring');
layer.features.add(feature);

function addAsync() src/collections/layer_features.cpp

Adds a feature to the layer. The feature should be created using the current layer as the definition.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
feature Feature
callback callback < void >
Throws Returns
Promise < void >
Example
var feature = new gdal.Feature(layer);
feature.setGeometry(new gdal.Point(0, 1));
feature.fields.set('name', 'somestring');
await layer.features.addAsync(feature);

function count() src/collections/layer_features.cpp

Returns the number of features in the layer.

Parameters
Parameter Type Description
force boolean
Returns
number

number of features in the layer.


function countAsync() src/collections/layer_features.cpp

Returns the number of features in the layer.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
force boolean
callback callback < number >
Returns
Promise < number >

number of features in the layer.


function first() src/collections/layer_features.cpp

Resets the feature pointer used by next() and returns the first feature in the layer.

Returns

function firstAsync() src/collections/layer_features.cpp

Resets the feature pointer used by next() and returns the first feature in the layer.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
callback callback < Feature >
Returns

function get() src/collections/layer_features.cpp

Fetch a feature by its identifier.

The id argument is not an index. In most cases it will be zero-based, but in some cases it will not. If iterating, it's best to use the next() method.

Parameters
Parameter Type Description
id number

The feature ID of the feature to read.

Throws Returns

function getAsync() src/collections/layer_features.cpp

Fetch a feature by its identifier.

The id argument is not an index. In most cases it will be zero-based, but in some cases it will not. If iterating, it's best to use the next() method.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
id number

The feature ID of the feature to read.

callback callback < Feature >
Throws Returns

function map() lib/default_iterators.js

Iterates through features using a callback function and builds an array of the returned values.

Parameters
Parameter Type Description
callback mapCb < Feature , U >

The callback to be called with each Feature

Returns
Array < U >
Example
var result = layer.features.map(function(array, i) {
    return value;
});

function next() src/collections/layer_features.cpp

Returns the next feature in the layer. Returns null if no more features.

Returns Example
while (feature = layer.features.next()) { ... }

function nextAsync() src/collections/layer_features.cpp

Returns the next feature in the layer. Returns null if no more features.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
callback callback < Feature >
Returns Example
while (feature = await layer.features.nextAsync()) { ... }

function remove() src/collections/layer_features.cpp

Removes a feature from the layer.

Parameters
Parameter Type Description
id number
Throws

function removeAsync() src/collections/layer_features.cpp

Removes a feature from the layer.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
id number
callback callback < void >
Throws Returns
Promise < void >

function set() src/collections/layer_features.cpp

Sets a feature in the layer.

Parameters
Parameter Type Description
feature Feature
Throws

function set() src/collections/layer_features.cpp

Sets a feature in the layer.

Parameters
Parameter Type Description
id number
feature Feature
Throws

function setAsync() src/collections/layer_features.cpp

Sets a feature in the layer.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
id number
feature Feature
callback callback < Feature >
Throws Returns


class Feature src/gdal_feature.cpp

A simple feature, including geometry and attributes. Its fields and geometry type is defined by the given definition.

Parameters
Parameter Type Description
definition Layer | FeatureDefn
Example
//create layer and specify geometry type
var layer = dataset.layers.create('mylayer', null, gdal.Point);

//setup fields for the given layer
layer.fields.add(new gdal.FieldDefn('elevation', gdal.OFTInteger));
layer.fields.add(new gdal.FieldDefn('name', gdal.OFTString));

//create feature using layer definition and then add it to the layer
var feature = new gdal.Feature(layer);
feature.fields.set('elevation', 13775);
feature.fields.set('name', 'Grand Teton');
feature.setGeometry(new gdal.Point(43.741208, -110.802414));
layer.features.add(feature);
Instance members

defn : FeatureDefn src/gdal_feature.cpp


fid : number src/gdal_feature.cpp


fields : FeatureFields src/gdal_feature.cpp


function clone() src/gdal_feature.cpp

Clones the feature.

Returns

function destroy() src/gdal_feature.cpp

Releases the feature from memory.


function equals() src/gdal_feature.cpp

Determines if the features are the same.

Parameters
Parameter Type Description
feature Feature
Returns
boolean

true if the features are the same, false if different


function getGeometry() src/gdal_feature.cpp

Returns the geometry of the feature.

Returns

function setFrom() src/gdal_feature.cpp

Set one feature from another. Overwrites the contents of this feature from the geometry and attributes of another.

Parameters
Parameter Type Description
feature Feature
index_map Array < number > | undefined

Array mapping each field from the source feature to the given index in the destination feature. -1 ignores the source field. The field types must still match otherwise the behavior is undefined.

forgiving boolean

true if the operation should continue despite lacking output fields matching some of the source fields.

Throws Example
var feature1 = new gdal.Feature(defn);
var feature2 = new gdal.Feature(defn);
feature1.setGeometry(new gdal.Point(5, 10));
feature1.fields.set([5, 'test', 3.14]);
feature2.setFrom(feature1);

function setGeometry() src/gdal_feature.cpp

Sets the feature's geometry.

Parameters
Parameter Type Description
geometry Geometry | null

new geometry or null to clear the field

Throws


class FeatureDefn src/gdal_feature_defn.cpp

Definition of a feature class or feature layer.

Instance members

fields : FeatureDefnFields src/gdal_feature_defn.cpp


geomIgnored : boolean src/gdal_feature_defn.cpp


geomType : number src/gdal_feature_defn.cpp

WKB geometry type ( see table


name : string src/gdal_feature_defn.cpp


styleIgnored : boolean src/gdal_feature_defn.cpp


function clone() src/gdal_feature_defn.cpp

Clones the feature definition.

Returns


class FeatureDefnFields src/collections/feature_defn_fields.cpp

An encapsulation of a FeatureDefn 's fields.

Instance members

featureDefn : FeatureDefn src/collections/feature_defn_fields.cpp

Returns the parent feature definition.


function add() src/collections/feature_defn_fields.cpp

Adds field definition(s).

Parameters
Parameter Type Description
fields FieldDefn | Array < FieldDefn >
Throws

function asyncIterator() : FieldDefn lib/default_iterators.js

Iterates through all field definitions using an async iterator

Example
for await (const array of featureDefn) {
}

function count() src/collections/feature_defn_fields.cpp

Returns the number of fields.

Returns
number

function forEach() lib/default_iterators.js

Iterates through all field definitions using a callback function.

Parameters
Parameter Type Description
callback forEachCb < FieldDefn >

The callback to be called with each FieldDefn

Example
featureDefn.forEach(function(array, i) { ... });

function get() src/collections/feature_defn_fields.cpp

Returns a field definition.

Parameters
Parameter Type Description
key string | number

Field name or index

Throws Returns

function getNames() src/collections/feature_defn_fields.cpp

Returns a list of field names.

Returns
Array < string >

List of field names.


function indexOf() src/collections/feature_defn_fields.cpp

Returns the index of field definition.

Parameters
Parameter Type Description
name string
Returns
number

Index or -1 if not found.


function map() lib/default_iterators.js

Iterates through field definitions using a callback function and builds an array of the returned values.

Parameters
Parameter Type Description
callback mapCb < FieldDefn , U >

The callback to be called with each FieldDefn

Returns
Array < U >
Example
var result = featureDefn.map(function(array, i) {
    return value;
});

function prototype() : FieldDefn lib/default_iterators.js

Iterates through all field definitions using an iterator

Example
for (const array of featureDefn) {
}

function remove() src/collections/feature_defn_fields.cpp

Removes a field definition.

Parameters
Parameter Type Description
key string | number

Field name or index

Throws

function reorder() src/collections/feature_defn_fields.cpp

Reorders the fields.

Parameters
Parameter Type Description
map Array < number >

An array representing the new field order.

Throws Example
// reverse fields:
featureDef.fields.reorder([2, 1, 0]);


class FeatureFields src/collections/feature_fields.cpp

An encapsulation of all field data that makes up a Feature .

Static members

function forEach() lib/iterators.js

Iterates through all fields using a callback function.

Parameters
Parameter Type Description
callback forEachCb < any >

The callback to be called with each feature value and key .

Example
layer.features.get(0).fields.forEach(function(value, key) { ... });

function toJSON() lib/iterators.js

Outputs the fields as a serialized JSON string.

Returns
string

Serialized JSON


Instance members

feature : Feature src/collections/feature_fields.cpp

Returns the parent feature.


function count() src/collections/feature_fields.cpp

Returns the number of fields.

Returns
number
Example
feature.fields.count();

function get() src/collections/feature_fields.cpp

Returns a field's value.

Parameters
Parameter Type Description
key string | number

Feature name or index.

Throws Returns
any
Example
value = feature.fields.get(0);
value = feature.fields.get('field');

function getNames() src/collections/feature_fields.cpp

Returns a list of field name.

Throws Returns
Array < string >

List of field names.


function indexOf() src/collections/feature_fields.cpp

Returns the index of a field, given its name.

Parameters
Parameter Type Description
name string
Returns
number

Index or, -1 if it cannot be found.

Example
var index = feature.fields.indexOf('field');

function map() lib/default_iterators.js

Iterates through field definitions using a callback function and builds an array of the returned values.

Parameters
Parameter Type Description
callback mapCb < any , U >

The callback to be called with each any

Returns
Array < U >
Example
var result = layer.features.get(0).fields.map(function(array, i) {
    return value;
});

function reset() src/collections/feature_fields.cpp

Resets all fields.

Parameters
Parameter Type Description
values object | undefined
Throws Returns
void
Example
feature.fields.reset();

function set() src/collections/feature_fields.cpp

Sets feature field(s).

Parameters
Parameter Type Description
key string | number

Field name or index

value any
Throws Example
// most-efficient, least flexible. requires you to know the ordering of the
fields: feature.fields.set(['Something']); feature.fields.set(0,
'Something');

// most flexible.
feature.fields.set({name: 'Something'});
feature.fields.set('name', 'Something');

function set() src/collections/feature_fields.cpp

Parameters
Parameter Type Description
fields object
Throws

function toArray() src/collections/feature_fields.cpp

Outputs the field values as a pure JS array.

Throws Returns
Array < any >

function toObject() src/collections/feature_fields.cpp

Outputs the field data as a pure JS object.

Throws Returns
any


class FieldDefn src/gdal_field_defn.cpp

Parameters
Parameter Type Description
name string

Field name

type string

Data type (see (OFT)|OFT

Instance members

ignored : boolean src/gdal_field_defn.cpp


justification : string src/gdal_field_defn.cpp

Field justification (see OJ constants )


name : string src/gdal_field_defn.cpp


precision : number src/gdal_field_defn.cpp


type : string src/gdal_field_defn.cpp

Data type (see OFT constants


width : number src/gdal_field_defn.cpp




Geometries

Classes representing vector geometries

class Geometry src/geometry/gdal_geometry.cpp

Abstract base class for all geometry classes.

Static members

wkbType : number src/geometry/gdal_geometry.cpp

See wkbGeometryType .


function toObject() lib/iterators.js

Converts the geometry to a GeoJSON object representation.

Returns
object

GeoJSON


Instance members

coordinateDimension : number src/geometry/gdal_geometry.cpp


dimension : number src/geometry/gdal_geometry.cpp


name : string src/geometry/gdal_geometry.cpp


points : LineStringPoints src/geometry/gdal_simplecurve.cpp

The points that make up the SimpleCurve geometry.


srs : SpatialReference | null src/geometry/gdal_geometry.cpp


wkbSize : number src/geometry/gdal_geometry.cpp


wkbType : number src/geometry/gdal_geometry.cpp

See wkbGeometryType .


function boundary() src/geometry/gdal_geometry.cpp

Compute boundary.

Throws Returns

function boundaryAsync() src/geometry/gdal_geometry.cpp

Compute boundary.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
callback callback < Geometry >
Throws Returns

function buffer() src/geometry/gdal_geometry.cpp

Buffers the geometry by the given distance.

Parameters
Parameter Type Description
distance number
segments number
Throws Returns

function bufferAsync() src/geometry/gdal_geometry.cpp

Buffers the geometry by the given distance.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
distance number
segments number
callback callback < Geometry >
Throws Returns

function centroid() src/geometry/gdal_geometry.cpp

Compute the centroid of the geometry.

Throws Returns

function centroidAsync() src/geometry/gdal_geometry.cpp

Compute the centroid of the geometry.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
callback callback < Geometry >
Throws Returns

function clone() src/geometry/gdal_geometry.cpp

Clones the instance.

Returns

function closeRings() src/geometry/gdal_geometry.cpp

Closes any un-closed rings.


function closeRingsAsync() src/geometry/gdal_geometry.cpp

Closes any un-closed rings.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
callback callback < void >
Returns
Promise < void >

function contains() src/geometry/gdal_geometry.cpp

Determines if the current geometry contains the provided geometry.

Parameters
Parameter Type Description
geometry Geometry
Returns
boolean

function containsAsync() src/geometry/gdal_geometry.cpp

Determines if the current geometry contains the provided geometry.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
geometry Geometry
callback callback < boolean >
Returns
Promise < boolean >

function convexHull() src/geometry/gdal_geometry.cpp

Compute convex hull.

Throws Returns

function convexHullAsync() src/geometry/gdal_geometry.cpp

Compute convex hull.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
callback callback < Geometry >
Throws Returns

function create() src/geometry/gdal_geometry.cpp

Creates an empty Geometry from a WKB type.

Parameters
Parameter Type Description
type number

WKB geometry type available options

Returns

function crosses() src/geometry/gdal_geometry.cpp

Determines if the two geometries cross.

Parameters
Parameter Type Description
geometry Geometry
Returns
boolean

function crossesAsync() src/geometry/gdal_geometry.cpp

Determines if the two geometries cross.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
geometry Geometry
callback callback < boolean >
Returns
Promise < boolean >

function difference() src/geometry/gdal_geometry.cpp

Compute the difference of this geometry with another.

Parameters
Parameter Type Description
geometry Geometry
Throws Returns

function differenceAsync() src/geometry/gdal_geometry.cpp

Compute the difference of this geometry with another.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
geometry Geometry
callback callback < Geometry >
Throws Returns

function disjoint() src/geometry/gdal_geometry.cpp

Determines if the two geometries are disjoint.

Parameters
Parameter Type Description
geometry Geometry
Returns
boolean

function disjointAsync() src/geometry/gdal_geometry.cpp

Determines if the two geometries are disjoint.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
geometry Geometry
callback callback < boolean >
Returns
Promise < boolean >

function distance() src/geometry/gdal_geometry.cpp

Computes the distance between the two geometries.

Parameters
Parameter Type Description
geometry Geometry
Returns
number

function distanceAsync() src/geometry/gdal_geometry.cpp

Computes the distance between the two geometries.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
geometry Geometry
callback callback < number >
Returns
Promise < number >

function empty() src/geometry/gdal_geometry.cpp

Clears the geometry.


function emptyAsync() src/geometry/gdal_geometry.cpp

Clears the geometry.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
callback callback < void >
Returns
Promise < void >

function equals() src/geometry/gdal_geometry.cpp

Determines if the two geometries equal each other.

Parameters
Parameter Type Description
geometry Geometry
Returns
boolean

function equalsAsync() src/geometry/gdal_geometry.cpp

Determines if the two geometries equal each other.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
geometry Geometry
callback callback < boolean >
Returns
Promise < boolean >

function flattenTo2D() src/geometry/gdal_geometry.cpp

Convert geometry to strictly 2D.

Returns
void

function flattenTo2DAsync() src/geometry/gdal_geometry.cpp

Convert geometry to strictly 2D.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
callback callback < void >
Returns
Promise < void >

function fromGeoJson() src/geometry/gdal_geometry.cpp

Creates a Geometry from a GeoJSON object fragment. The async version depends on V8 for object serialization and this part is not parallelizable. V8 objects cannot be accessed outside of the main thread. This function should not be used for importing objects of more than few tens of Kbytes when low latency is needed. If you need to import very large GeoJSON geometries in server code, use the much faster and completely parallel fromGeoJonBuffer(Async)

Parameters
Parameter Type Description
geojson object
Throws Returns

function fromGeoJsonAsync() src/geometry/gdal_geometry.cpp

Creates a Geometry from a GeoJSON object fragment. The async version depends on V8 for object serialization and this part is not parallelizable. V8 objects cannot be accessed outside of the main thread. This function should not be used for importing objects of more than few tens of Kbytes when low latency is needed. If you need to import very large GeoJSON geometries in server code, use the much faster and completely parallel fromGeoJonBuffer(Async)

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
geojson object
callback callback < Geometry >
Throws Returns

function fromGeoJsonBuffer() src/geometry/gdal_geometry.cpp

Creates a Geometry from a buffer containing a GeoJSON fragment in UT8 format.

Parameters
Parameter Type Description
geojson Buffer
Throws Returns

function fromGeoJsonBufferAsync() src/geometry/gdal_geometry.cpp

Creates a Geometry from a buffer containing a GeoJSON fragment in UT8 format.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
geojson Buffer
callback callback < Geometry >
Throws Returns

function fromWKB() src/geometry/gdal_geometry.cpp

Creates a Geometry from a WKB buffer.

Parameters
Parameter Type Description
wkb Buffer
srs SpatialReference | undefined
Throws Returns

function fromWKBAsync() src/geometry/gdal_geometry.cpp

Creates a Geometry from a WKB buffer.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
wkb Buffer
srs SpatialReference | undefined
callback callback < Geometry >
Throws Returns

function fromWKT() src/geometry/gdal_geometry.cpp

Creates a Geometry from a WKT string.

Parameters
Parameter Type Description
wkt string
srs SpatialReference | undefined
Throws Returns

function fromWKTAsync() src/geometry/gdal_geometry.cpp

Creates a Geometry from a WKT string.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
wkt string
srs SpatialReference | undefined
callback callback < Geometry >
Throws Returns

function getConstructor() src/geometry/gdal_geometry.cpp

Returns the Geometry subclass that matches the given WKB geometry type.

Parameters
Parameter Type Description
type number

WKB geometry type available options

Returns
Function

function getEnvelope() src/geometry/gdal_geometry.cpp

Computes the bounding box (envelope).

Returns
Envelope

Bounding envelope


function getEnvelope3D() src/geometry/gdal_geometry.cpp

Computes the 3D bounding box (envelope).

Returns
Envelope3D

Bounding envelope


function getEnvelope3DAsync() src/geometry/gdal_geometry.cpp

Computes the 3D bounding box (envelope).

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
callback callback < Geometry >
Returns

function getEnvelopeAsync() src/geometry/gdal_geometry.cpp

Computes the bounding box (envelope).

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
callback callback < Envelope >
Returns

function getName() src/geometry/gdal_geometry.cpp

Returns the Geometry subclass name that matches the given WKB geometry type.

Parameters
Parameter Type Description
type number

WKB geometry type available options

Returns
string

function intersection() src/geometry/gdal_geometry.cpp

Compute intersection with another geometry.

Parameters
Parameter Type Description
geometry Geometry
Throws Returns

function intersectionAsync() src/geometry/gdal_geometry.cpp

Compute intersection with another geometry.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
geometry Geometry
callback callback < Geometry >
Throws Returns

function intersects() src/geometry/gdal_geometry.cpp

Determines if the two geometries intersect.

Parameters
Parameter Type Description
geometry Geometry
Returns
boolean

function intersectsAsync() src/geometry/gdal_geometry.cpp

Determines if the two geometries intersect.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
geometry Geometry
callback callback < boolean >
Returns
Promise < boolean >

function isEmpty() src/geometry/gdal_geometry.cpp

Determines if the geometry is empty.

Returns
boolean

function isEmptyAsync() src/geometry/gdal_geometry.cpp

Determines if the geometry is empty.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
callback callback < boolean >
Returns
Promise < boolean >

function isRing() src/geometry/gdal_geometry.cpp

Determines if the geometry is a ring.

Returns
boolean

function isRingAsync() src/geometry/gdal_geometry.cpp

Determines if the geometry is a ring.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
callback callback < boolean >
Returns
Promise < boolean >

function isSimple() src/geometry/gdal_geometry.cpp

Determines if the geometry is simple.

Returns
boolean

function isSimpleAsync() src/geometry/gdal_geometry.cpp

Determines if the geometry is simple.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
callback callback < boolean >
Returns
Promise < boolean >

function isValid() src/geometry/gdal_geometry.cpp

Determines if the geometry is valid.

Returns
boolean

function isValidAsync() src/geometry/gdal_geometry.cpp

Determines if the geometry is valid.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
callback callback < boolean >
Returns
Promise < boolean >

function makeValid() src/geometry/gdal_geometry.cpp

Attempts to make an invalid geometry valid without losing vertices. Requires GDAL 3.0

Throws Returns

function makeValidAsync() src/geometry/gdal_geometry.cpp

Attempts to make an invalid geometry valid without losing vertices. Requires GDAL 3.0

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
callback callback < Geometry >
Returns

function overlaps() src/geometry/gdal_geometry.cpp

Determines if the current geometry overlaps the provided geometry.

Parameters
Parameter Type Description
geometry Geometry
Returns
boolean

function overlapsAsync() src/geometry/gdal_geometry.cpp

Determines if the current geometry overlaps the provided geometry.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
geometry Geometry
callback callback < boolean >
Returns
Promise < boolean >

function segmentize() src/geometry/gdal_geometry.cpp

Modify the geometry such it has no segment longer then the given distance.

Parameters
Parameter Type Description
segment_length number
Returns
void

function simplify() src/geometry/gdal_geometry.cpp

Reduces the geometry complexity.

Parameters
Parameter Type Description
tolerance number
Throws Returns

function simplifyAsync() src/geometry/gdal_geometry.cpp

Reduces the geometry complexity.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
tolerance number
callback callback < Geometry >
Throws Returns

function simplifyPreserveTopology() src/geometry/gdal_geometry.cpp

Reduces the geometry complexity while preserving the topology.

Parameters
Parameter Type Description
tolerance number
Throws Returns

function simplifyPreserveTopologyAsync() src/geometry/gdal_geometry.cpp

Reduces the geometry complexity while preserving the topology.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
tolerance number
callback callback < Geometry >
Throws Returns

function swapXY() src/geometry/gdal_geometry.cpp

Swaps x, y coordinates.


function swapXYAsync() src/geometry/gdal_geometry.cpp

Swaps x, y coordinates.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
callback callback < void >
Returns
Promise < void >

function symDifference() src/geometry/gdal_geometry.cpp

Computes the symmetric difference of this geometry and the second geometry.

Parameters
Parameter Type Description
geometry Geometry
Throws Returns

function symDifferenceAsync() src/geometry/gdal_geometry.cpp

Computes the symmetric difference of this geometry and the second geometry.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
geometry Geometry
callback callback < Geometry >
Throws Returns

function toGML() src/geometry/gdal_geometry.cpp

Convert a geometry into GML format.

Throws Returns
string

function toGMLAsync() src/geometry/gdal_geometry.cpp

Convert a geometry into GML format.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
callback callback < string >
Throws Returns
Promise < string >

function toJSON() src/geometry/gdal_geometry.cpp

Convert a geometry into JSON format.

Throws Returns
string

function toJSONAsync() src/geometry/gdal_geometry.cpp

Convert a geometry into JSON format.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
callback callback < string >
Throws Returns
Promise < string >

function toKML() src/geometry/gdal_geometry.cpp

Convert a geometry into KML format.

Throws Returns
string

function toKMLAsync() src/geometry/gdal_geometry.cpp

Convert a geometry into KML format.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
callback callback < string >
Throws Returns
Promise < string >

function touches() src/geometry/gdal_geometry.cpp

Determines if the two geometries touch.

Parameters
Parameter Type Description
geometry Geometry
Returns
boolean

function touchesAsync() src/geometry/gdal_geometry.cpp

Determines if the two geometries touch.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
geometry Geometry
callback callback < boolean >
Returns
Promise < boolean >

function toWKB() src/geometry/gdal_geometry.cpp

Convert a geometry into well known binary format.

Parameters
Parameter Type Description
byte_order string

see options

variant string

( see options )

Throws Returns
Buffer

function toWKBAsync() src/geometry/gdal_geometry.cpp

Convert a geometry into well known binary format.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
byte_order string

see options

variant string

( see options )

callback callback < Buffer >
Throws Returns
Promise < Buffer >

function toWKT() src/geometry/gdal_geometry.cpp

Convert a geometry into well known text format.

Throws Returns
string

function toWKTAsync() src/geometry/gdal_geometry.cpp

Convert a geometry into well known text format.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
callback callback < string >
Throws Returns
Promise < string >

function transform() src/geometry/gdal_geometry.cpp

Apply arbitrary coordinate transformation to the geometry.

This method will transform the coordinates of a geometry from their current spatial reference system to a new target spatial reference system. Normally this means reprojecting the vectors, but it could include datum shifts, and changes of units.

Note that this method does not require that the geometry already have a spatial reference system. It will be assumed that they can be treated as having the source spatial reference system of the CoordinateTransformation object, and the actual SRS of the geometry will be ignored.

Parameters
Parameter Type Description
transformation CoordinateTransformation
Throws

function transformAsync() src/geometry/gdal_geometry.cpp

Apply arbitrary coordinate transformation to the geometry.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
transformation CoordinateTransformation
callback callback < void >
Throws Returns
Promise < void >

function transformTo() src/geometry/gdal_geometry.cpp

Transforms the geometry to match the provided SpatialReference

Parameters
Parameter Type Description
srs SpatialReference
Throws

function transformToAsync() src/geometry/gdal_geometry.cpp

Transforms the geometry to match the provided SpatialReference

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
srs SpatialReference
callback callback < void >
Throws Returns
Promise < void >

function union() src/geometry/gdal_geometry.cpp

Compute the union of this geometry with another.

Parameters
Parameter Type Description
geometry Geometry
Throws Returns

function unionAsync() src/geometry/gdal_geometry.cpp

Compute the union of this geometry with another.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
geometry Geometry
callback callback < Geometry >
Throws Returns

function within() src/geometry/gdal_geometry.cpp

Determines if the current geometry is within the provided geometry.

Parameters
Parameter Type Description
geometry Geometry
Returns
boolean

function withinAsync() src/geometry/gdal_geometry.cpp

Determines if the current geometry is within the provided geometry.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
geometry Geometry
callback callback < boolean >
Returns
Promise < boolean >


class GeometryCollection src/geometry/gdal_geometrycollection.cpp

A collection of 1 or more geometry objects.

Instance members

children : GeometryCollectionChildren src/geometry/gdal_geometrycollection.cpp

All geometries represented by this collection.


function getArea() src/geometry/gdal_geometrycollection.cpp

Computes the combined area of the geometries.

Returns
number

function getLength() src/geometry/gdal_geometrycollection.cpp

Compute the length of a multicurve.

Returns
number


class GeometryCollectionChildren src/collections/geometry_collection_children.cpp

A collection of Geometries, used by GeometryCollection .

Instance members

function add() src/collections/geometry_collection_children.cpp

Adds geometry(s) to the collection.

Parameters
Parameter Type Description
geometry Geometry | Array < Geometry >
Example
// one at a time:
geometryCollection.children.add(new Point(0,0,0));

// add many at once:
geometryCollection.children.add([
    new Point(1,0,0),
    new Point(1,0,0)
]);

function count() src/collections/geometry_collection_children.cpp

Returns the number of items.

Returns
number

function forEach() lib/default_iterators.js

Iterates through all child geometries using a callback function.

Parameters
Parameter Type Description
callback forEachCb < Geometry >

The callback to be called with each Geometry

Example
geometryCollection.children.forEach(function(array, i) { ... });

function get() src/collections/geometry_collection_children.cpp

Returns the geometry at the specified index.

Parameters
Parameter Type Description
index number

0-based index

Throws Returns

function map() lib/default_iterators.js

Iterates through child geometries using a callback function and builds an array of the returned values.

Parameters
Parameter Type Description
callback mapCb < Geometry , U >

The callback to be called with each Geometry

Returns
Array < U >
Example
var result = geometryCollection.children.map(function(array, i) {
    return value;
});

function prototype() : Geometry lib/default_iterators.js

Iterates through all child geometries using an iterator

Example
for (const array of geometryCollection.children) {
}

function remove() src/collections/geometry_collection_children.cpp

Removes the geometry at the specified index.

Parameters
Parameter Type Description
index number

0-based index, -1 for all geometries



class CircularString src/geometry/gdal_circularstring.cpp

Concrete representation of an arc.

Example
var CircularString = new gdal.CircularString();
CircularString.points.add(new gdal.Point(0,0));
CircularString.points.add(new gdal.Point(0,10));

class CompoundCurve src/geometry/gdal_compoundcurve.cpp

Concrete representation of a compound contionuos curve.

Example
var CompoundCurve = new gdal.CompoundCurve();
CompoundCurve.points.add(new gdal.Point(0,0));
CompoundCurve.points.add(new gdal.Point(0,10));
Instance members

curves : CompoundCurveCurves src/geometry/gdal_compoundcurve.cpp

Points that make up the compound curve.



class CompoundCurveCurves src/collections/compound_curves.cpp

A collection of connected curves, used by CompoundCurve

Instance members

function add() src/collections/compound_curves.cpp

Adds a curve to the collection.

Parameters
Parameter Type Description
curves SimpleCurve | Array < SimpleCurve >
Example
var ring1 = new gdal.CircularString();
ring1.points.add(0,0);
ring1.points.add(1,0);
ring1.points.add(1,1);
ring1.points.add(0,1);
ring1.points.add(0,0);

// one at a time:
compound.curves.add(ring1);

// many at once:
compound.curves.add([ring1, ...]);

function asyncIterator() : SimpleCurve lib/default_iterators.js

Iterates through all curves using an async iterator

Example
for await (const array of compoundCurves.curves) {
}

function count() src/collections/compound_curves.cpp

Returns the number of curves that exist in the collection.

Returns
number

function forEach() lib/default_iterators.js

Iterates through all curves using a callback function.

Parameters
Parameter Type Description
callback forEachCb < SimpleCurve >

The callback to be called with each SimpleCurve

Example
compoundCurves.curves.forEach(function(array, i) { ... });

function get() src/collections/compound_curves.cpp

Returns the curve at the specified index.

Parameters
Parameter Type Description
index number
Throws Returns Example
var curve0 = compound.curves.get(0);
var curve1 = compound.curves.get(1);

function map() lib/default_iterators.js

Iterates through curves using a callback function and builds an array of the returned values.

Parameters
Parameter Type Description
callback mapCb < SimpleCurve , U >

The callback to be called with each SimpleCurve

Returns
Array < U >
Example
var result = compoundCurves.curves.map(function(array, i) {
    return value;
});

function prototype() : SimpleCurve lib/default_iterators.js

Iterates through all curves using an iterator

Example
for (const array of compoundCurves.curves) {
}

function toArray() lib/default_iterators.js

Outputs all curves as a regular javascript array.

Returns


class LinearRing src/geometry/gdal_linearring.cpp

Concrete representation of a closed ring.

Instance members

function getArea() src/geometry/gdal_linearring.cpp

Computes the area enclosed by the ring.

Returns
number


class LineString src/geometry/gdal_linestring.cpp

Concrete representation of a multi-vertex line.

Example
var lineString = new gdal.LineString();
lineString.points.add(new gdal.Point(0,0));
lineString.points.add(new gdal.Point(0,10));

class LineStringPoints src/collections/linestring_points.cpp

An encapsulation of a LineString 's points.

Instance members

function add() src/collections/linestring_points.cpp

Adds point(s) to the line string. Also accepts any object with an x and y property.

Parameters
Parameter Type Description
points Point | xyz | Array < Point | xyz >
Throws Example
lineString.points.add(new gdal.Point(1, 2));
lineString.points.add([
    new gdal.Point(1, 2)
    new gdal.Point(3, 4)
]);

function add() src/collections/linestring_points.cpp

Parameters
Parameter Type Description
x number
y number
z number | undefined
Throws

function count() src/collections/linestring_points.cpp

Returns the number of points that are part of the line string.

Returns
number

function forEach() lib/default_iterators.js

Iterates through all points using a callback function.

Parameters
Parameter Type Description
callback forEachCb < Point >

The callback to be called with each Point

Example
lineString.points.forEach(function(array, i) { ... });

function get() src/collections/linestring_points.cpp

Returns the point at the specified index.

Parameters
Parameter Type Description
index number

0-based index

Throws Returns

function map() lib/default_iterators.js

Iterates through points using a callback function and builds an array of the returned values.

Parameters
Parameter Type Description
callback mapCb < Point , U >

The callback to be called with each Point

Returns
Array < U >
Example
var result = lineString.points.map(function(array, i) {
    return value;
});

function prototype() : Point lib/default_iterators.js

Iterates through all points using an iterator

Example
for (const array of lineString.points) {
}

function resize() src/collections/linestring_points.cpp

Adjusts the number of points that make up the line string.

Parameters
Parameter Type Description
count number

function reverse() src/collections/linestring_points.cpp

Reverses the order of all the points.


function set() src/collections/linestring_points.cpp

Sets the point at the specified index.

Parameters
Parameter Type Description
index number

0-based index

point Point | xyz
Throws Example
lineString.points.set(0, new gdal.Point(1, 2));

function set() src/collections/linestring_points.cpp

Parameters
Parameter Type Description
index number

0-based index

x number
y number
z number | undefined
Throws

function toArray() lib/default_iterators.js

Outputs all points as a regular javascript array.

Returns
Array < Point >

List of Point instances



class MultiCurve src/geometry/gdal_multicurve.cpp

Instance members

function polygonize() src/geometry/gdal_multicurve.cpp

Converts it to a polygon.

Returns


class MultiLineString src/geometry/gdal_multilinestring.cpp

Instance members

function polygonize() src/geometry/gdal_multilinestring.cpp

Converts it to a polygon.

Returns


class MultiPoint src/geometry/gdal_multipoint.cpp


class MultiPolygon src/geometry/gdal_multipolygon.cpp

Instance members

function getArea() src/geometry/gdal_multipolygon.cpp

Computes the combined area of the collection.

Returns
number

function unionCascaded() src/geometry/gdal_multipolygon.cpp

Unions all the geometries and returns the result.

Returns


class Point src/geometry/gdal_point.cpp

Point class.

Parameters
Parameter Type Description
x number
y number
z number | undefined
Instance members

x : number src/geometry/gdal_point.cpp


y : number src/geometry/gdal_point.cpp


z : number src/geometry/gdal_point.cpp



class Polygon src/geometry/gdal_polygon.cpp

Concrete class representing polygons.

Instance members

rings : PolygonRings src/geometry/gdal_polygon.cpp

The rings that make up the polygon geometry.


function getArea() src/geometry/gdal_polygon.cpp

Computes the area of the polygon.

Returns
number


class PolygonRings src/collections/polygon_rings.cpp

A collection of polygon rings, used by Polygon .

Instance members

function add() src/collections/polygon_rings.cpp

Adds a ring to the collection.

Parameters
Parameter Type Description
rings LinearRing | Array < LinearRing >
Example
var ring1 = new gdal.LinearRing();
ring1.points.add(0,0);
ring1.points.add(1,0);
ring1.points.add(1,1);
ring1.points.add(0,1);
ring1.points.add(0,0);

// one at a time:
polygon.rings.add(ring1);

// many at once:
polygon.rings.add([ring1, ...]);

function count() src/collections/polygon_rings.cpp

Returns the number of rings that exist in the collection.

Returns
number

function forEach() lib/default_iterators.js

Iterates through all rings using a callback function.

Parameters
Parameter Type Description
callback forEachCb < LineString >

The callback to be called with each LineString

Example
polygon.rings.forEach(function(array, i) { ... });

function get() src/collections/polygon_rings.cpp

Returns the ring at the specified index. The ring at index 0 will always be the polygon's exterior ring.

Parameters
Parameter Type Description
index number
Throws Returns Example
var exterior = polygon.rings.get(0);
var interior = polygon.rings.get(1);

function map() lib/default_iterators.js

Iterates through rings using a callback function and builds an array of the returned values.

Parameters
Parameter Type Description
callback mapCb < LineString , U >

The callback to be called with each LineString

Returns
Array < U >
Example
var result = polygon.rings.map(function(array, i) {
    return value;
});

function prototype() : LineString lib/default_iterators.js

Iterates through all rings using an iterator

Example
for (const array of polygon.rings) {
}

function toArray() lib/default_iterators.js

Outputs all rings as a regular javascript array.

Returns


class SimpleCurve src/geometry/gdal_simplecurve.cpp

Abstract class representing all SimpleCurves.

Instance members

function addSubLineString() src/geometry/gdal_simplecurve.cpp

Add a segment of another LineString to this SimpleCurve subtype.

Adds the request range of vertices to the end of this compound curve in an efficient manner. If the start index is larger than the end index then the vertices will be reversed as they are copied.

Parameters
Parameter Type Description
LineString LineString

to be added

start number

the first vertex to copy, defaults to 0 to start with the first vertex in the other LineString

end number

the last vertex to copy, defaults to -1 indicating the last vertex of the other LineString

Returns
void

function getLength() src/geometry/gdal_simplecurve.cpp

Compute the length of a multiSimpleCurve.

Returns
number

function value() src/geometry/gdal_simplecurve.cpp

Returns the point at the specified distance along the SimpleCurve.

Parameters
Parameter Type Description
distance number
Returns


class Envelope lib/envelope.js

A 2D bounding box. For 3D envelopes, see Envelope3D

(Pure-javascript implementation of OGREnvelope )

Parameters
Parameter Type Description
bounds object | undefined

An object containing minX , maxX , minY , and maxY values.

Properties
Property Type Description
minX number
maxX number
minY number
maxY number
Static members

function contains() lib/envelope.js

Determines if the provided envelope is wholly-contained by the current envelope.

Parameters
Parameter Type Description
envelope Envelope
Returns
boolean

function intersect() lib/envelope.js

Updates the envelope to the intersection of the two envelopes.

Parameters
Parameter Type Description
envelope Envelope
Returns
void

function intersects() lib/envelope.js

Determines if the provided envelope touches it.

Parameters
Parameter Type Description
envelope Envelope
Returns
boolean

function isEmpty() lib/envelope.js

Determines if the envelope has not been set yet.

Returns
boolean

function merge() lib/envelope.js

Unions the provided envelope with the current envelope.

Parameters
Parameter Type Description
envelope Envelope
Returns
void

function merge() lib/envelope.js

Unions the provided envelope with the x/y coordinates provided.

Parameters
Parameter Type Description
x number
y number
Returns
void

function toPolygon() lib/envelope.js

Converts the envelope to a polygon.

Returns


class Envelope3D lib/envelope_3d.js

A 3D bounding box. For 2D envelopes, see Envelope

(Pure-javascript implementation of OGREnvelope3D )

Parameters
Parameter Type Description
bounds object | undefined

An object containing minX , maxX , minY , maxY , minZ , and maxZ values.

Properties
Property Type Description
minX number
maxX number
minY number
maxY number
minZ number
maxZ number
Static members

function contains() lib/envelope_3d.js

Determines if the provided envelope is wholly-contained by the current envelope.

Parameters
Parameter Type Description
envelope Envelope3D
Returns
boolean

function intersect() lib/envelope_3d.js

Updates the envelope to the intersection of the two envelopes.

Parameters
Parameter Type Description
envelope Envelope3D
Returns
void

function intersects() lib/envelope_3d.js

Determines if the provided envelope touches it.

Parameters
Parameter Type Description
envelope Envelope3D
Returns
boolean

function isEmpty() lib/envelope_3d.js

Determines if the envelope has not been set yet.

Returns
boolean

function merge() lib/envelope_3d.js

Unions the provided envelope with the current envelope.

Parameters
Parameter Type Description
envelope Envelope3D
Returns
void

function merge() lib/envelope_3d.js

Unions the provided envelope with the x/y/z coordinates provided.

Parameters
Parameter Type Description
x number
y number
z number
Returns
void



Multi-Dimensional Model

Classes for working with the Multi-Dimensional Data Model

class ArrayAttributes src/collections/array_attributes.cpp

An encapsulation of a Array descendant attributes.

Instance members

ds src/collections/array_attributes.cpp

Returns the parent dataset.


names : Array < string > src/collections/array_attributes.cpp

Attributes' names.


function asyncIterator() : Attribute lib/default_iterators.js

Iterates through all attributes using an async iterator

Example
for await (const array of array.attributes) {
}

function count() src/collections/array_attributes.cpp

Returns the number of attributes in the collection.

Returns
number

function countAsync() src/collections/array_attributes.cpp

Returns the number of attributes in the collection.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
callback callback < number >
Returns
Promise < number >

function forEach() lib/default_iterators.js

Iterates through all attributes using a callback function.

Parameters
Parameter Type Description
callback forEachCb < Attribute >

The callback to be called with each Attribute

Example
array.attributes.forEach(function(array, i) { ... });

function get() src/collections/array_attributes.cpp

Returns the attribute with the given name/index.

Parameters
Parameter Type Description
attribute string | number
Returns

function getAsync() src/collections/array_attributes.cpp

Returns the attribute with the given name/index.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
attribute string | number
callback callback < Attribute >
Returns

function map() lib/default_iterators.js

Iterates through attributes using a callback function and builds an array of the returned values.

Parameters
Parameter Type Description
callback mapCb < Attribute , U >

The callback to be called with each Attribute

Returns
Array < U >
Example
var result = array.attributes.map(function(array, i) {
    return value;
});

function prototype() : Attribute lib/default_iterators.js

Iterates through all attributes using an iterator

Example
for (const array of array.attributes) {
}


class ArrayDimensions src/collections/array_dimensions.cpp

An encapsulation of a MDArray descendant dimensions.

Example
const dimensions = group.dimensions;
Instance members

ds : Dataset src/collections/array_dimensions.cpp

Returns the parent dataset.


names : Array < string > src/collections/array_dimensions.cpp

Dimensions' names.


parent : Group src/collections/array_dimensions.cpp

Returns the parent group.


function asyncIterator() : Dimension lib/default_iterators.js

Iterates through all dimensions using an async iterator

Example
for await (const array of array.dimensions) {
}

function count() src/collections/array_dimensions.cpp

Returns the number of dimensions in the collection.

Returns
number

function countAsync() src/collections/array_dimensions.cpp

Returns the number of dimensions in the collection.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
callback callback < number >
Returns
Promise < number >

function forEach() lib/default_iterators.js

Iterates through all dimensions using a callback function.

Parameters
Parameter Type Description
callback forEachCb < Dimension >

The callback to be called with each Dimension

Example
array.dimensions.forEach(function(array, i) { ... });

function get() src/collections/array_dimensions.cpp

Returns the array with the given name/index.

Parameters
Parameter Type Description
array string | number
Returns

function getAsync() src/collections/array_dimensions.cpp

Returns the array with the given name/index.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
array string | number
callback callback < Dimension >
Returns

function map() lib/default_iterators.js

Iterates through dimensions using a callback function and builds an array of the returned values.

Parameters
Parameter Type Description
callback mapCb < Dimension , U >

The callback to be called with each Dimension

Returns
Array < U >
Example
var result = array.dimensions.map(function(array, i) {
    return value;
});

function prototype() : Dimension lib/default_iterators.js

Iterates through all dimensions using an iterator

Example
for (const array of array.dimensions) {
}


class Attribute src/gdal_attribute.cpp

A representation of a group with access methods.

Instance members

dataType : string src/gdal_attribute.cpp


value : string | number src/gdal_attribute.cpp

Complex GDAL data types introduced in 3.1 are not yet supported

Throws


class Dimension src/gdal_dimension.cpp

A representation of a group with access methods.

Instance members

description : string src/gdal_dimension.cpp


direction : string src/gdal_dimension.cpp


size : number src/gdal_dimension.cpp


type : string src/gdal_dimension.cpp



class Group src/gdal_group.cpp

A representation of a group with access methods.

Instance members

arrays : GroupArrays src/gdal_group.cpp


attributes : GroupAttributes src/gdal_group.cpp


description : string src/gdal_group.cpp


dimensions : GroupDimensions src/gdal_group.cpp


groups : GroupGroups src/gdal_group.cpp



class GroupArrays src/collections/group_arrays.cpp

An encapsulation of a Group descendant arrays.

Instance members

ds : Dataset src/collections/group_arrays.cpp

Returns the parent dataset.


names : Array < string > src/collections/group_arrays.cpp


function asyncIterator() : MDArray lib/default_iterators.js

Iterates through all arrays using an async iterator

Example
for await (const array of group.arrays) {
}

function count() src/collections/group_arrays.cpp

Returns the number of arrays in the collection.

Returns
number

function countAsync() src/collections/group_arrays.cpp

Returns the number of arrays in the collection.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
callback callback < number >
Returns
Promise < number >

function forEach() lib/default_iterators.js

Iterates through all arrays using a callback function.

Parameters
Parameter Type Description
callback forEachCb < MDArray >

The callback to be called with each MDArray

Example
group.arrays.forEach(function(array, i) { ... });

function get() src/collections/group_arrays.cpp

Returns the array with the given name/index.

Parameters
Parameter Type Description
array string | number
Returns

function getAsync() src/collections/group_arrays.cpp

Returns the array with the given name/index.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
array string | number
callback callback < MDArray >
Returns

function map() lib/default_iterators.js

Iterates through arrays using a callback function and builds an array of the returned values.

Parameters
Parameter Type Description
callback mapCb < MDArray , U >

The callback to be called with each MDArray

Returns
Array < U >
Example
var result = group.arrays.map(function(array, i) {
    return value;
});

function prototype() : MDArray lib/default_iterators.js

Iterates through all arrays using an iterator

Example
for (const array of group.arrays) {
}


class GroupAttributes src/collections/group_attributes.cpp

An encapsulation of a Group descendant attributes.

Instance members

ds : Dataset src/collections/group_attributes.cpp

Returns the parent dataset.


names : Array < string > src/collections/group_attributes.cpp


function asyncIterator() : Attribute lib/default_iterators.js

Iterates through all attributes using an async iterator

Example
for await (const array of group.attributes) {
}

function count() src/collections/group_attributes.cpp

Returns the number of attributes in the collection.

Returns
number

function countAsync() src/collections/group_attributes.cpp

Returns the number of attributes in the collection.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
callback callback < number >
Returns
Promise < number >

function forEach() lib/default_iterators.js

Iterates through all attributes using a callback function.

Parameters
Parameter Type Description
callback forEachCb < Attribute >

The callback to be called with each Attribute

Example
group.attributes.forEach(function(array, i) { ... });

function get() src/collections/group_attributes.cpp

Returns the attribute with the given name/index.

Parameters
Parameter Type Description
attribute string | number
Returns

function getAsync() src/collections/group_attributes.cpp

Returns the attribute with the given name/index.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
attribute string | number
callback callback < Attribute >
Returns

function map() lib/default_iterators.js

Iterates through attributes using a callback function and builds an array of the returned values.

Parameters
Parameter Type Description
callback mapCb < Attribute , U >

The callback to be called with each Attribute

Returns
Array < U >
Example
var result = group.attributes.map(function(array, i) {
    return value;
});

function prototype() : Attribute lib/default_iterators.js

Iterates through all attributes using an iterator

Example
for (const array of group.attributes) {
}


class GroupDimensions src/collections/group_dimensions.cpp

An encapsulation of a Group descendant dimensions.

Example
const dimensions = group.dimensions;
Instance members

ds : Dataset src/collections/group_dimensions.cpp

Returns the parent dataset.


names : Array < string > src/collections/group_dimensions.cpp


function asyncIterator() : Dimension lib/default_iterators.js

Iterates through all dimensions using an async iterator

Example
for await (const array of group.dimensions) {
}

function count() src/collections/group_dimensions.cpp

Returns the number of dimensions in the collection.

Returns
number

function countAsync() src/collections/group_dimensions.cpp

Returns the number of dimensions in the collection.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
callback callback < number >
Returns
Promise < number >

function forEach() lib/default_iterators.js

Iterates through all dimensions using a callback function.

Parameters
Parameter Type Description
callback forEachCb < Dimension >

The callback to be called with each Dimension

Example
group.dimensions.forEach(function(array, i) { ... });

function get() src/collections/group_dimensions.cpp

Returns the array with the given name/index.

Parameters
Parameter Type Description
array string | number
Returns

function getAsync() src/collections/group_dimensions.cpp

Returns the array with the given name/index.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
array string | number
callback callback < Dimension >
Returns

function map() lib/default_iterators.js

Iterates through dimensions using a callback function and builds an array of the returned values.

Parameters
Parameter Type Description
callback mapCb < Dimension , U >

The callback to be called with each Dimension

Returns
Array < U >
Example
var result = group.dimensions.map(function(array, i) {
    return value;
});

function prototype() : Dimension lib/default_iterators.js

Iterates through all dimensions using an iterator

Example
for (const array of group.dimensions) {
}


class GroupGroups src/collections/group_groups.cpp

An encapsulation of a Group descendant groups.

Instance members

ds : Dataset src/collections/group_groups.cpp

Returns the parent dataset.


names : Array < string > src/collections/group_groups.cpp


function asyncIterator() : Group lib/default_iterators.js

Iterates through all groups using an async iterator

Example
for await (const array of group.groups) {
}

function count() src/collections/group_groups.cpp

Returns the number of groups in the collection.

Returns
number

function countAsync() src/collections/group_groups.cpp

Returns the number of groups in the collection.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
callback callback < number >
Returns
Promise < number >

function forEach() lib/default_iterators.js

Iterates through all groups using a callback function.

Parameters
Parameter Type Description
callback forEachCb < Group >

The callback to be called with each Group

Example
group.groups.forEach(function(array, i) { ... });

function get() src/collections/group_groups.cpp

Returns the group with the given name/index.

Parameters
Parameter Type Description
group string | number
Returns

function getAsync() src/collections/group_groups.cpp

Returns the group with the given name/index.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
group string | number
callback callback < Group >
Returns

function map() lib/default_iterators.js

Iterates through groups using a callback function and builds an array of the returned values.

Parameters
Parameter Type Description
callback mapCb < Group , U >

The callback to be called with each Group

Returns
Array < U >
Example
var result = group.groups.map(function(array, i) {
    return value;
});

function prototype() : Group lib/default_iterators.js

Iterates through all groups using an iterator

Example
for (const array of group.groups) {
}


class MDArray src/gdal_mdarray.cpp

A representation of an array with access methods.

Instance members

attributes : ArrayAttributes src/gdal_mdarray.cpp


dataType : string src/gdal_mdarray.cpp


description : string src/gdal_mdarray.cpp


dimensions : GroupDimensions src/gdal_mdarray.cpp


length : number src/gdal_mdarray.cpp

The flattened length of the array.


noDataValue : number | null src/gdal_mdarray.cpp

No data value for this array.


offset : number src/gdal_mdarray.cpp

Raster value offset.


scale : number src/gdal_mdarray.cpp

Raster value scale.


srs : SpatialReference src/gdal_mdarray.cpp

Spatial reference associated with MDArray.

Throws

unitType : string src/gdal_mdarray.cpp

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.


function asDataset() src/gdal_mdarray.cpp

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
Parameter Type Description
x number | string

dimension to be used as X axis

y number | string

dimension to be used as Y axis

Throws Returns

function getMask() src/gdal_mdarray.cpp

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.

Throws Returns

function getView() src/gdal_mdarray.cpp

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
Parameter Type Description
view string
Throws Returns

function read() src/gdal_mdarray.cpp

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
Parameter Type Description
options MDArrayOptions
Throws Returns

function readAsync() src/gdal_mdarray.cpp

Read data from the MDArray.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
options MDArrayOptions
callback callback < TypedArray >
Throws Returns
Promise < TypedArray >

A TypedArray of values.




Streams

Raster Data Integration with Node.js Streams

class RasterMuxStream lib/multiplexer.js

Multiplexer stream

Reads multiple input RasterReadStream streams and outputs a single} synchronized stream with multiple data elements.

All the input streams must have the same length.

Can be used with RasterTransform which will automatically apply a function over the whole chunk.

Parameters
Parameter Type Description
inputs Record < string , RasterReadStream >

Input streams

options RasterReadableOptions | undefined
Example
const dsT2m = gdal.open('AROME_T2m_10.tiff'));
 const dsD2m = gdal.open('AROME_D2m_10.tiff'));

 const dsCloudBase = gdal.open('CLOUDBASE.tiff', 'w', 'GTiff',
   dsT2m.rasterSize.x, dsT2m.rasterSize.y, 1, gdal.GDT_Float64);

 const mux = new gdal.RasterMuxStream({
   T2m: dsT2m.bands.get(1).pixels.createReadStream(),
   D2m: dsD2m.bands.get(1).pixels.createReadStream()
 });
 const ws = dsCloudBase.bands.get(1).pixels.createWriteStream();

 // Espy's estimation for cloud base height (lifted condensation level)
 // LCL = 125 * (T2m - Td2m)
 // where T2m is the temperature at 2m and Td2m is the dew point at 2m
 const espyEstimation = new Transform({
   objectMode: true,
   transform(chunk, _, cb) {
     const lcl = new Float64Array(chunk.T2m.length)
     for (let i = 0; i < chunk.T2m.length; i++) {
       lcl[i] = 125 * (chunk.T2m[i] - chunk.D2m[i])
     }
     cb(null, lcl)
   }
 })

 mux.pipe(espyEstimation).pipe(ws);

class RasterReadStream lib/readable.js

Class implementing RasterBand reading as a stream of pixels}

Reading is buffered and it is aligned on the underlying compression blocks for maximum efficiency when possible

Pixels are streamed in row-major order

Parameters
Parameter Type Description
options RasterReadableOptions | undefined

class RasterTransform lib/multiplexer.js

A raster Transform stream

Applies a function on all data elements.

Input must be a RasterMuxStream

calcAsync provides a higher-level interface for the same feature, while an even lower-level API is available by manually extending stream.Transform as illustrated in the gdal.RasterMuxStream example.

Parameters
Parameter Type Description
options RasterTransformOptions | undefined
Example
const dsT2m = gdal.open('AROME_T2m_10.tiff'));
 const dsD2m = gdal.open('AROME_D2m_10.tiff'));

 const dsCloudBase = gdal.open('CLOUDBASE.tiff', 'w', 'GTiff',
   dsT2m.rasterSize.x, dsT2m.rasterSize.y, 1, gdal.GDT_Float64);

 const mux = new gdal.RasterMuxStream({
   T2m: dsT2m.bands.get(1).pixels.createReadStream(),
   D2m: dsD2m.bands.get(1).pixels.createReadStream()
 });
 const ws = dsCloudBase.bands.get(1).pixels.createWriteStream();

 // Espy's estimation for cloud base height (lifted condensation level)
 // LCL = 125 * (T2m - Td2m)
 // where T2m is the temperature at 2m and Td2m is the dew point at 2m
 const fn = (t,td) => 125 * (t - td);
 const espyEstimation = new RasterTransform({ type: Float64Array, fn });

 mux.pipe(espyEstimation).pipe(ws);

class RasterWriteStream lib/writable.js

Class implementing RasterBand writing as a stream of pixels

Writing is buffered and it is aligned on the underlying compression blocks for maximum efficiency when possible

When piping between rasters using identical blocks, the transfer is zero-copy

The input stream must be in row-major order

If the data type of the stream is different from the data type of the file, GDAL will automatically convert. Mixing data types across chunks is not supported, all chunks must have the same type.

Writing is zero-copy when writing chunks that are exact multiples of the underlying stream block size as returned by gdal.RasterBandPixels.blockSize

Block are written only when full, so the stream must receive exactly width * height pixels to write the last block

Parameters
Parameter Type Description
options RasterWritableOptions | undefined


Constants

All constants

CPL Error Codes

constant CE_Debug : number src/node_gdal.cpp

Error level: Debug


constant CE_Failure : number src/node_gdal.cpp

Error level: Failure


constant CE_Fatal : number src/node_gdal.cpp

Error level: Fatal


constant CE_None : number src/node_gdal.cpp

Error level: (no error)


constant CE_Warning : number src/node_gdal.cpp

Error level: Warning


constant CPLE_AppDefined : number src/node_gdal.cpp


constant CPLE_AssertionFailed : number src/node_gdal.cpp


constant CPLE_FileIO : number src/node_gdal.cpp


constant CPLE_IllegalArg : number src/node_gdal.cpp


constant CPLE_None : number src/node_gdal.cpp


constant CPLE_NotSupported : number src/node_gdal.cpp


constant CPLE_NoWriteAccess : number src/node_gdal.cpp


constant CPLE_objectNull : number src/node_gdal.cpp


constant CPLE_OpenFailed : number src/node_gdal.cpp


constant CPLE_OutOfMemory : number src/node_gdal.cpp


constant CPLE_UserInterrupt : number src/node_gdal.cpp



Dataset creation

constant DCAP_CREATE : string src/node_gdal.cpp


constant DCAP_CREATECOPY : string src/node_gdal.cpp


constant DCAP_VIRTUALIO : string src/node_gdal.cpp



Dimensions

constant DIM_HORIZONTAL_X : string src/node_gdal.cpp


constant DIM_HORIZONTAL_Y : string src/node_gdal.cpp


constant DIM_PARAMETRIC : string src/node_gdal.cpp


constant DIM_TEMPORAL : string src/node_gdal.cpp


constant DIM_VERTICAL : string src/node_gdal.cpp


constant DIR_DOWN : string src/node_gdal.cpp


constant DIR_EAST : string src/node_gdal.cpp


constant DIR_FUTURE : string src/node_gdal.cpp


constant DIR_NORTH : string src/node_gdal.cpp


constant DIR_PAST : string src/node_gdal.cpp


constant DIR_SOUTH : string src/node_gdal.cpp


constant DIR_UP : string src/node_gdal.cpp


constant DIR_WEST : string src/node_gdal.cpp



DMD

constant DMD_CREATIONDATATYPES : string src/node_gdal.cpp


constant DMD_CREATIONOPTIONLIST : string src/node_gdal.cpp


constant DMD_EXTENSION : string src/node_gdal.cpp


constant DMD_HELPTOPIC : string src/node_gdal.cpp


constant DMD_LONGNAME : string src/node_gdal.cpp


constant DMD_MIMETYPE : string src/node_gdal.cpp



IO Flags

constant GA_Readonly : number src/node_gdal.cpp


constant GA_Update : number src/node_gdal.cpp


constant GF_Read : number src/node_gdal.cpp


constant GF_Write : number src/node_gdal.cpp



Color Interpretation

constant GCI_AlphaBand : string src/node_gdal.cpp


constant GCI_BlackBand : string src/node_gdal.cpp


constant GCI_BlueBand : string src/node_gdal.cpp


constant GCI_CyanBand : string src/node_gdal.cpp


constant GCI_GrayIndex : string src/node_gdal.cpp


constant GCI_GreenBand : string src/node_gdal.cpp


constant GCI_HueBand : string src/node_gdal.cpp


constant GCI_LightnessBand : string src/node_gdal.cpp


constant GCI_MagentaBand : string src/node_gdal.cpp


constant GCI_PaletteIndex : string src/node_gdal.cpp


constant GCI_RedBand : string src/node_gdal.cpp


constant GCI_SaturationBand : string src/node_gdal.cpp


constant GCI_Undefined : string src/node_gdal.cpp


constant GCI_YCbCr_CbBand : string src/node_gdal.cpp


constant GCI_YCbCr_CrBand : string src/node_gdal.cpp


constant GCI_YCbCr_YBand : string src/node_gdal.cpp


constant GCI_YellowBand : string src/node_gdal.cpp


constant GPI_CMYK : string src/node_gdal.cpp

CMYK


constant GPI_Gray : string src/node_gdal.cpp

Grayscale, only c1 defined


constant GPI_HLS : string src/node_gdal.cpp

HLS, c4 is not defined


constant GPI_RGB : string src/node_gdal.cpp

RGBA, alpha in c4



Pixel Types

constant GDT_Byte : string src/node_gdal.cpp

Eight bit unsigned integer


constant GDT_CFloat32 : string src/node_gdal.cpp

Complex Float32


constant GDT_CFloat64 : string src/node_gdal.cpp

Complex Float64


constant GDT_CInt16 : string src/node_gdal.cpp

Complex Int16


constant GDT_CInt32 : string src/node_gdal.cpp

Complex Int32


constant GDT_Float32 : string src/node_gdal.cpp

Thirty two bit floating point


constant GDT_Float64 : string src/node_gdal.cpp

Sixty four bit floating point


constant GDT_Int16 : string src/node_gdal.cpp

Sixteen bit signed integer


constant GDT_Int32 : string src/node_gdal.cpp

Thirty two bit signed integer


constant GDT_UInt16 : string src/node_gdal.cpp

Sixteen bit unsigned integer


constant GDT_UInt32 : string src/node_gdal.cpp

Thirty two bit unsigned integer


constant GDT_Unknown : string src/node_gdal.cpp

Unknown or unspecified type


constant GEDTC_Compound : string src/node_gdal.cpp

String extended type for MDArrays (GDAL >= 3.1)


constant GEDTC_String : string src/node_gdal.cpp

String extended type for MDArrays (GDAL >= 3.1)



Resampling Algorithms

constant GRA_Average : string src/node_gdal.cpp


constant GRA_Bilinear : string src/node_gdal.cpp


constant GRA_Cubic : string src/node_gdal.cpp


constant GRA_CubicSpline : string src/node_gdal.cpp


constant GRA_Lanczos : string src/node_gdal.cpp


constant GRA_Mode : string src/node_gdal.cpp


constant GRA_NearestNeighbor : string src/node_gdal.cpp



ODsCC

constant ODrCCreateDataSource : string src/node_gdal.cpp


constant ODrCDeleteDataSource : string src/node_gdal.cpp


constant ODsCCreateGeomFieldAfterCreateLayer : string src/node_gdal.cpp


constant ODsCCreateLayer : string src/node_gdal.cpp


constant ODsCDeleteLayer : string src/node_gdal.cpp



Feature Field Types

constant OFTBinary : string src/node_gdal.cpp


constant OFTDate : string src/node_gdal.cpp


constant OFTDateTime : string src/node_gdal.cpp


constant OFTInteger : string src/node_gdal.cpp


constant OFTInteger64 : string src/node_gdal.cpp


constant OFTInteger64List : string src/node_gdal.cpp


constant OFTIntegerList : string src/node_gdal.cpp


constant OFTReal : string src/node_gdal.cpp


constant OFTRealList : string src/node_gdal.cpp


constant OFTString : string src/node_gdal.cpp


constant OFTStringList : string src/node_gdal.cpp


constant OFTTime : string src/node_gdal.cpp


constant OFTWideString : string src/node_gdal.cpp


constant OFTWideStringList : string src/node_gdal.cpp



Justification

constant OJLeft : string src/node_gdal.cpp


constant OJRight : string src/node_gdal.cpp


constant OJUndefined : string src/node_gdal.cpp



OLC

constant OLCAlterFieldDefn : string src/node_gdal.cpp


constant OLCCreateField : string src/node_gdal.cpp


constant OLCCreateGeomField : string src/node_gdal.cpp


constant OLCDeleteFeature : string src/node_gdal.cpp


constant OLCDeleteField : string src/node_gdal.cpp


constant OLCFastFeatureCount : string src/node_gdal.cpp


constant OLCFastGetExtent : string src/node_gdal.cpp


constant OLCFastSetNextByIndex : string src/node_gdal.cpp


constant OLCFastSpatialFilter : string src/node_gdal.cpp


constant OLCIgnoreFields : string src/node_gdal.cpp


constant OLCRandomRead : string src/node_gdal.cpp


constant OLCRandomWrite : string src/node_gdal.cpp


constant OLCReorderFields : string src/node_gdal.cpp


constant OLCSequentialWrite : string src/node_gdal.cpp


constant OLCStringsAsUTF8 : string src/node_gdal.cpp


constant OLCTransactions : string src/node_gdal.cpp



wkbGeometryType

constant wkb25DBit : number src/node_gdal.cpp

Example
// 2 -> 2.5D
wkbPoint25D = gdal.wkbPoint | gdal.wkb25DBit

// 2.5D -> 2D (same as wkbFlatten())
wkbPoint = gdal.wkbPoint25D & (~gdal.wkb25DBit)

constant wkbCircularString : number src/node_gdal.cpp


constant wkbCompoundCurve : number src/node_gdal.cpp


constant wkbGeometryCollection : number src/node_gdal.cpp


constant wkbGeometryCollection25D : number src/node_gdal.cpp


constant wkbLinearRing : string src/node_gdal.cpp


constant wkbLinearRing25D : number src/node_gdal.cpp


constant wkbLineString : number src/node_gdal.cpp


constant wkbLineString25D : number src/node_gdal.cpp


constant wkbMultiCurve : number src/node_gdal.cpp


constant wkbMultiLineString : number src/node_gdal.cpp


constant wkbMultiLineString25D : number src/node_gdal.cpp


constant wkbMultiPoint : number src/node_gdal.cpp


constant wkbMultiPoint25D : number src/node_gdal.cpp


constant wkbMultiPolygon : number src/node_gdal.cpp


constant wkbMultiPolygon25D : number src/node_gdal.cpp



wkbByteOrder

constant wkbNDR : string src/node_gdal.cpp


constant wkbXDR : string src/node_gdal.cpp


constant wkbNone : number src/node_gdal.cpp


constant wkbPoint : number src/node_gdal.cpp


constant wkbPoint25D : number src/node_gdal.cpp


constant wkbPolygon : number src/node_gdal.cpp


constant wkbPolygon25D : number src/node_gdal.cpp


constant wkbUnknown : number src/node_gdal.cpp



wkbVariant

constant wkbVariantIso : string src/node_gdal.cpp

SFSQL 1.2 and ISO SQL/MM Part 3 extended dimension (Z&M) WKB types.


constant wkbVariantOgc : string src/node_gdal.cpp

Old-style 99-402 extended dimension (Z) WKB types. Synonymous with 'wkbVariantOldOgc' (gdal >= 2.0)


constant wkbVariantOldOgc : string src/node_gdal.cpp

Old-style 99-402 extended dimension (Z) WKB types. Synonymous with 'wkbVariantOgc' (gdal < 2.0)




Data Types

typedef forEachCb : Function lib/iterators.js


typedef mapCb : Function lib/default_iterators.js

Parameters
Parameter Type Description
object T
index number
Returns
U

typedef callback : Function lib/gdal.js

Callback using the standard Node.js error convention

Parameters
Parameter Type Description
err Error
result any

typedef stats : object src/gdal_rasterband.cpp

Properties
Property Type Description
min number
max number
mean number
std_dev number

typedef units : object src/gdal_spatial_reference.cpp

Properties
Property Type Description
units string
value number

interface xyz lib/gdal.js

Properties
Property Type Description
x number
y number
z number | undefined

interface RasterReadableOptions lib/readable.js

Properties
Property Type Description
blockOptimize boolean | undefined
convertNoData boolean | undefined

interface RasterWritableOptions lib/writable.js

Properties
Property Type Description
blockOptimize boolean | undefined
convertNoData boolean | undefined

interface RasterTransformOptions lib/multiplexer.js

Properties
Property Type Description
fn Function

Function to be applied on all data


typedef CalcOptions : object lib/calc.js

Properties
Property Type Description
convertNoData boolean | undefined
convertInput boolean | undefined
progress_cb ProgressCb | undefined

typedef ContourOptions : object src/gdal_algorithms.cpp

Properties
Property Type Description
src RasterBand
dst Layer
offset number | undefined
interval number | undefined
fixedLevels Array < number > | undefined
nodata number | undefined
idField number | undefined
elevField number | undefined
progress_cb ProgressCb | undefined

typedef CreateOptions : object src/gdal_driver.cpp

Properties
Property Type Description
progress_cb ProgressCb | undefined

typedef FillOptions : object src/gdal_algorithms.cpp

Properties
Property Type Description
src RasterBand
mask RasterBand | undefined
searchDist number
smoothingIterations number | undefined

typedef MDArrayOptions : object src/gdal_mdarray.cpp

Properties
Property Type Description
origin Array < number >
span Array < number >
stride Array < number > | undefined
data_type string | undefined
data TypedArray | undefined
_offset number | undefined

typedef PixelFunction : Uint8Array src/gdal_algorithms.cpp


typedef PolygonizeOptions : object src/gdal_algorithms.cpp

Properties
Property Type Description
src RasterBand
dst Layer
mask RasterBand | undefined
pixValField number

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

connectedness number | undefined

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

useFloats boolean | undefined

Use floating point buffers instead of int buffers.

progress_cb ProgressCb | undefined

typedef ProgressCb : Function lib/gdal.js

Parameters
Parameter Type Description
complete number
msg string

typedef ProgressOptions : object lib/gdal.js

Properties
Property Type Description
progress_cb ProgressCb

typedef ReprojectOptions : object src/gdal_warper.cpp

Properties
Property Type Description
src Dataset
dst Dataset
s_srs SpatialReference
t_srs SpatialReference
resampling string | undefined
cutline Geometry | undefined
srcBands Array < number > | undefined
dstBands Array < number > | undefined
srcAlphaBand number | undefined
dstAlphaBand number | undefined
srcNodata number | undefined
dstNodata number | undefined
blend number | undefined
memoryLimit number | undefined
maxError number | undefined
multi boolean | undefined
options object | undefined
progress_cb ProgressCb | undefined

typedef SieveOptions : object src/gdal_algorithms.cpp

Properties
Property Type Description
src RasterBand
dst RasterBand
mask RasterBand | undefined
threshold number
connectedness number | undefined
progress_cb ProgressCb | undefined

typedef StringOptions : Array < string > | Record < string , string | number | Array < string | number > > src/node_gdal.cpp


typedef UtilOptions : object src/gdal_utils.cpp

Properties
Property Type Description
progress_cb ProgressCb | undefined

typedef VRTBandDescriptor : object lib/wrapVRT.js

Properties
Property Type Description
sources Array < RasterBand >

Source data raster bands

pixelFunc string | undefined

Pixel function to be applied when reading data, must be a GDAL builtin function or a registered user function

pixelFuncArgs Record < string , string | number > | undefined

Additional arguments for the pixel function

dataType string | undefined

Data type to convert the pixels to

sourceTransferType string | undefined

Data type to be used as input of the pixel function when reading from the source

description string | undefined

Optional band description


typedef VRTDescriptor : object lib/wrapVRT.js

Properties
Property Type Description
bands Array < VRTBandDescriptor >

typedef WarpOptions : object src/gdal_warper.cpp

Properties
Property Type Description
src Dataset
s_srs SpatialReference
t_srs SpatialReference
maxError number | undefined

typedef WarpOutput : object src/gdal_warper.cpp

Properties
Property Type Description
rasterSize xyz
geoTransform Array < number >


Global Parameters

constant version : string src/node_gdal.cpp

GDAL version (not the binding version)


constant bundled : boolean src/node_gdal.cpp

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


constant drivers : GDALDrivers src/node_gdal.cpp

The collection of all drivers registered with GDAL


lastError : object src/node_gdal.cpp

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


function verbose() src/node_gdal.cpp

Displays extra debugging information from GDAL.


eventLoopWarning : boolean src/node_gdal.cpp

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



Utilities

function addPixelFunc() src/gdal_algorithms.cpp

Register a new compiled pixel function for derived virtual datasets.

This method is not meant to be used directly by the end user, it is an entry point for plugins implementing pixel functions.

You can check the gdal-exprtk plugin for an implementation which uses ExprTk expressions.

Parameters
Parameter Type Description
name string
pixelFn PixelFunction
Throws

function buildVRT() src/gdal_utils.cpp

Library version of gdalbuildvrt.

Parameters
Parameter Type Description
dst_path string | null

destination path, null for an in-memory operation

src_ds Array < Dataset > | Array < string >

array of source datasets

args Array < string > | undefined

array of CLI options for gdalbuildvrt

options UtilOptions | undefined

additional options

Throws Returns Example
const ds1 = gdal.buildVRT('/vsimem/target.tiff',
   [ 'input1.tif', 'input2.tif' ],
   [ '-resolution', 'highest' ] );

const ds2 = gdal.buildVRT('/vsimem/target.tiff',
   [ gdal.open('input1.tif'), gdal.open('input2.tif') ],
   [ '-resolution', 'highest' ] );

function buildVRTAsync() src/gdal_utils.cpp

Library version of gdalbuildvrt.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
dst_path string | null

destination path, null for an in-memory operation

src_ds Array < Dataset > | Array < string >

array of source datasets

args Array < string > | undefined

array of CLI options for gdalbuildvrt

options UtilOptions | undefined

additional options

callback callback < Dataset >
Throws Returns Example
const ds1 = await gdal.buildVRTAsync('/vsimem/target.tiff',
   [ 'input1.tif', 'input2.tif' ],
   [ '-resolution', 'highest' ] );

const ds2 = gdal.buildVRT('/vsimem/target.tiff',
   [ await gdal.openAsync('input1.tif'), await gdal.openAsync('input2.tif') ],
   [ '-resolution', 'highest' ] );

function calcAsync() lib/calc.js

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.

It internally uses a RasterTransform which can also be used directly for a finer-grained control over the transformation.

You can check the gdal-exprtk plugin for an alternative implementation which uses an ExprTk expression instead of a JS function and performs only O(1) operations on the main thread

There is no sync version

Parameters
Parameter Type Description
inputs Record < string , RasterBand >

An object containing all the input bands

output RasterBand

Output raster band

options CalcOptions | undefined

Options

Returns
Promise < void >
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 });

function checksumImage() src/gdal_algorithms.cpp

Compute checksum for image region.

Parameters
Parameter Type Description
src RasterBand
x number
y number
w number
h number
Throws Returns
number

function checksumImageAsync() src/gdal_algorithms.cpp

Compute checksum for image region.

Parameters
Parameter Type Description
src RasterBand
x number
y number
w number
h number
callback callback < number >
Throws Returns
number Promise < number >

function contourGenerate() src/gdal_algorithms.cpp

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
Parameter Type Description
options ContourOptions
Throws

function contourGenerateAsync() src/gdal_algorithms.cpp

Create vector contours from raster DEM.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
options ContourOptions
callback callback < void >
Throws Returns
Promise < void >

function createPixelFunc() lib/gdal.js

Create a GDAL pixel function from a JS expression for one pixel.

Higher-level API of gdal.toPixelFunc .

Returns Example
// This example will register a new GDAL pixel function called sum2
// that requires a VRT dataset with 2 values per pixel
gdal.addPixelFunc('sum2', gdal.createPixelFunc((a, b) => a + b));

function createPixelFuncWithArgs() lib/gdal.js

Create a GDAL pixel function from a JS expression for one pixel.

Same as gdal.createPixelFunc but passes an object with the static arguments from the VRT descriptor.

Returns Example
// This example will register a new GDAL pixel function called sum2
// that requires a VRT dataset with 2 values per pixel
gdal.addPixelFunc('sum2', gdal.createPixelFuncWithArgs((args, a, b) => args.k + a + b));

function decToDMS() src/node_gdal.cpp

Convert decimal degrees to degrees, minutes, and seconds string.

Parameters
Parameter Type Description
angle number
axis string

"lat" or "long"

precision number
Returns
string

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


function dem() src/gdal_utils.cpp

Library version of gdaldem.

Parameters
Parameter Type Description
dst_path string

destination path

src_ds Dataset

source dataset

mode 'hillshade' | 'slope' | 'aspect' | 'color-relief' | 'TRI' | 'TPI' | 'Roughness'

processing mode

args Array < string > | undefined

array of CLI options for gdaldem

colorFile string | undefined

optional color filename, see https://gdal.org/programs/gdaldem.html for more details

options UtilOptions | undefined

additional options

Throws Returns Example
const ds = gdal.open('input.tif')
const output = gdal.dem('/vsimem/output.tiff', ds, 'hillshade',  [ '-z', '2' ])

function demAsync() src/gdal_utils.cpp

Library version of gdaldem.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
dst_path string

destination path

src_ds Dataset

source dataset

mode 'hillshade' | 'slope' | 'aspect' | 'color-relief' | 'TRI' | 'TPI' | 'Roughness'

processing mode

args Array < string > | undefined

array of CLI options for gdaldem

colorFile string | undefined

optional color filename, see https://gdal.org/programs/gdaldem.html for more details

options UtilOptions | undefined

additional options

callback callback < Dataset >
Throws Returns Example
const ds = await gdal.openAsync('input.tif')
const output = await gdal.demAsync('/vsimem/output.tiff', ds, 'hillshade', [ '-z', '2' ])

function fillNodata() src/gdal_algorithms.cpp

Fill raster regions by interpolation from edges.

Parameters
Parameter Type Description
options FillOptions
Throws

function fillNodataAsync() src/gdal_algorithms.cpp

Fill raster regions by interpolation from edges.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
options FillOptions
callback callback < void >
Throws Returns
Promise < void >

function fromDataType() lib/gdal.js

Returns a TypedArray constructor from a GDAL data type

Parameters
Parameter Type Description
dataType string | null
Throws

TypeError

Example
const array = new (gdal.fromDataType(band.dataType))(band.size.x * band.size.y)
`

function info() src/gdal_utils.cpp

Library version of gdalinfo.

Parameters
Parameter Type Description
dataset Dataset
args Array < string > | undefined

array of CLI options for gdalinfo

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

function infoAsync() src/gdal_utils.cpp

Library version of gdalinfo.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
dataset Dataset
args Array < string > | undefined

array of CLI options for gdalinfo

callback callback < string >
Throws Returns
Promise < string >
Example
const ds = gdal.open('input.tif')
const output = gdal.info('/vsimem/temp.tif')

function polygonize() src/gdal_algorithms.cpp

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
Parameter Type Description
options PolygonizeOptions
Throws

function polygonizeAsync() src/gdal_algorithms.cpp

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.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
options PolygonizeOptions
callback callback < void >
Throws Returns
Promise < void >

function quiet() src/node_gdal.cpp

Disables all output.


function rasterize() src/gdal_utils.cpp

Library version of gdal_rasterize.

Parameters
Parameter Type Description
destination string | Dataset
source Dataset

dataset

args Array < string > | undefined

array of CLI options for gdal_rasterize

options UtilOptions | undefined

additional options

Throws Returns Example
const ds1 = gdal.rasterize('/vsimem/target.tiff',
   src_ds,
   [ '-b', '1' ] );

const ds2 = gdal.rasterize(dst_ds,
   src_ds,
   [ '-b', '1' ] );

function rasterizeAsync() src/gdal_utils.cpp

Library version of gdal_rasterize.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
destination string | Dataset
source Dataset

dataset

args Array < string > | undefined

array of CLI options for gdal_rasterize

options UtilOptions | undefined

additional options

callback callback < Dataset >
Throws Returns Example
const ds1 = await gdal.rasterizeAsync('/vsimem/target.tiff',
   src_ds,
   [ '-b', '1' ] );

const ds2 = await gdal.rasterizeAsync(dst_ds,
   src_ds,
   [ '-b', '1' ] );

function reprojectImage() src/gdal_warper.cpp

Reprojects a dataset.

Parameters
Parameter Type Description
options ReprojectOptions
Throws

function reprojectImageAsync() src/gdal_warper.cpp

Reprojects a dataset.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
options ReprojectOptions
callback callback < void >
Throws Returns
Promise < void >

function setPROJSearchPaths() src/node_gdal.cpp

Set paths where proj will search it data.

Parameters
Parameter Type Description
path string

c:\ProjData


function sieveFilter() src/gdal_algorithms.cpp

Removes small raster polygons.

Parameters
Parameter Type Description
options SieveOptions
Throws

function sieveFilterAsync() src/gdal_algorithms.cpp

Removes small raster polygons.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
options SieveOptions
callback callback < void >
Throws Returns
Promise < void >

function suggestedWarpOutput() src/gdal_warper.cpp

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

Parameters
Parameter Type Description
options WarpOptions

Warp options

Throws Returns
WarpOutput

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


function suggestedWarpOutputAsync() src/gdal_warper.cpp

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

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
options WarpOptions

Warp options

callback callback < WarpOutput >
Throws Returns

function toDataType() lib/gdal.js

Returns a GDAL data type from a TypedArray

Parameters
Parameter Type Description
array TypedArray
Throws

TypeError

Returns
string
Example
const dataType = gdal.fromDataType(array)
`

function toPixelFunc() src/gdal_algorithms.cpp

Create a GDAL pixel function from a JS function.

As V8, and JS in general, can only have a single active JS context per isolate, even when using async I/O, the pixel function will be called on the main thread. This can lead to increased latency when serving network requests.

You can check the gdal-exprtk plugin for an alternative which uses ExprTk expressions and does not suffer from this problem.

As GDAL does not allow unregistering a previously registered pixel functions, each call of this method will produce a permanently registered pixel function.

The function signature should match the GDAL pixel function signature. You can check createPixelFunc for a higher-level method that can be used to construct a GDAL pixel function from a JavaScript expression for a single pixel.

Throws Returns Example
// This example will register a new GDAL pixel function called sum2
// that requires a VRT dataset with 2 values per pixel
const sum2 = (sources: gdal.TypedArray[], buffer: gdal.TypedArray) => {
  for (let i = 0; i < buffer.length; i++) {
    buffer[i] = sources[0][i] + sources[1][i]
  }
};
gdal.addPixelFunc('sum2', gdal.toPixelFunc(sum2));

function translate() src/gdal_utils.cpp

Library version of gdal_translate.

Parameters
Parameter Type Description
destination string

destination filename

source Dataset

source dataset

args Array < string > | undefined

array of CLI options for gdal_translate

options UtilOptions | undefined

additional options

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

function translateAsync() src/gdal_utils.cpp

Library version of gdal_translate.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
destination string

destination filename

source Dataset

source dataset

args Array < string > | undefined

array of CLI options for gdal_translate

options UtilOptions | undefined

additional options

callback callback < Dataset >
Throws Returns Example
const ds = gdal.open('input.tif')
const out = gdal.translate('/vsimem/temp.tif', ds, [ '-b', '1' ])

function vectorTranslate() src/gdal_utils.cpp

Library version of ogr2ogr.

Parameters
Parameter Type Description
destination string | Dataset

destination

source Dataset

source dataset

args Array < string > | undefined

array of CLI options for ogr2ogr

options UtilOptions | undefined

additional options

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

function vectorTranslateAsync() src/gdal_utils.cpp

Library version of ogr2ogr.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
destination string | Dataset

destination

source Dataset

source dataset

args Array < string > | undefined

array of CLI options for ogr2ogr

options UtilOptions | undefined

additional options

callback callback < Dataset >
Throws Returns Example
const ds = gdal.open('input.geojson')
const out = gdal.vectorTranslate('/vsimem/temp.gpkg', ds, [ '-of', 'GPKG' ])

function warp() src/gdal_utils.cpp

Library version of gdalwarp.

Parameters
Parameter Type Description
dst_path string | null

destination path, null for an in-memory operation

dst_ds Dataset | null

destination dataset, null for a new dataset

src_ds Array < Dataset >

array of source datasets

args Array < string > | undefined

array of CLI options for gdalwarp

options UtilOptions | undefined

additional options

Throws Returns Example
const ds = gdal.open('input.tif')
const output = gdal.warp('/vsimem/output.tiff', null, [ ds ], [ '-t_srs', 'epsg:3587' ])

function warpAsync() src/gdal_utils.cpp

Library version of gdalwarp.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
dst_path string | null

destination path, null for an in-memory operation

dst_ds Dataset | null

destination dataset, null for a new dataset

src_ds Array < Dataset >

array of source datasets

args Array < string > | undefined

array of CLI options for gdalwarp

options UtilOptions | undefined

additional options

callback callback < Dataset >
Throws Returns Example
const ds = await gdal.openAsync('input.tif')
const output = await gdal.warpAsync('/vsimem/output.tiff', null, [ ds ], [ '-t_srs', 'epsg:3587' ])

function wrapVRT() lib/wrapVRT.js

Produces a VRT Dataset from a regular Dataset.

Supports applying pixel functions.

Parameters
Parameter Type Description
desc VRTDescriptor

Band descriptors

Returns
string
Example
// create a VRT dataset with a single band derived from the first
// band of the given dataset by applying the given pixel function
const ds = gdal.open(gdal.wrapVRT({
 bands: [
   {
     sources: [ gdal.open('test/data/sample.tif').bands.get(1) ],
     pixelFunc: 'inv',
     pixelFuncArgs: { k: 3 },
     type: gdal.GDT_Int16,
     sourceTransferType: gdal.GDT_Float32
   }
 ]
}));

// create a VRT dataset by applying a pixel function over
// all bands of the given dataset
const ds = gdal.open(gdal.wrapVRT({
   bands: gdal.open('test/data/multiband.tif').bands.map((b) => ({
     sources: [ b ],
     pixelFunc: 'inv',
     pixelFuncArgs: { k: 3 }
   }))
}));

// use a pixel function to combine two bands from two files in one band
const ds = gdal.open(gdal.wrapVRT({
 bands: [
   {
     sources: [
       gdal.open(path.join('test', 'data', 'AROME_T2m_10.tiff')).bands.get(1),
       gdal.open(path.join('test', 'data', 'AROME_D2m_10.tiff')).bands.get(1)
     ],
     pixelFunc: 'espy'
   }
 ]
}));


namespace config lib/gdal.js

function get() lib/gdal.js

Gets a GDAL configuration setting.

Parameters
Parameter Type Description
key string
Returns
string | null
Example
data_path = gdal.config.get('GDAL_DATA');

function set() lib/gdal.js

Sets a GDAL configuration setting.

Parameters
Parameter Type Description
key string
value string | null
Returns
void
Example
gdal.config.set('GDAL_DATA', data_path);


namespace fs src/gdal_fs.cpp

GDAL VSI layer file operations.

typedef VSIStat : object src/gdal_fs.cpp

Properties
Property Type Description
dev number
mode number
nlink number
uid number
gid number
rdev number
blksize number
ino number
size number
blocks number
atime Date
mtime Date
ctime Date

typedef VSIStat64 : object src/gdal_fs.cpp

Properties
Property Type Description
dev BigInt
mode BigInt
nlink BigInt
uid BigInt
gid BigInt
rdev BigInt
blksize BigInt
ino BigInt
size BigInt
blocks BigInt
atime Date
mtime Date
ctime Date

function readDir() src/gdal_fs.cpp

Read file names in a directory.

Parameters
Parameter Type Description
directory string
Throws Returns
Array < string >

function readDirAsync() src/gdal_fs.cpp

Read file names in a directory.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
directory string
callback callback < Array < string > >
Throws Returns
Promise < Array < string > >

function stat() src/gdal_fs.cpp

Get VSI file info.

Parameters
Parameter Type Description
filename string
bigint false

Return BigInt numbers. JavaScript numbers are safe for integers up to 2^53.

Throws Returns Example
const gdalStats = gdal.fs.stat('/vsis3/noaa-gfs-bdp-pds/gfs.20210918/06/atmos/gfs.t06z.pgrb2.0p25.f010')
if ((gdalStats.mode & fs.constants.S_IFREG) === fs.constants.S_IFREG) console.log('is regular file')

// convert to Node.js fs.Stats
const fsStats = new (Function.prototype.bind.apply(fs.Stats, [null, ...Object.keys(s).map(k => s[k])]))
if (fsStats.isFile) console.log('is regular file')

function stat() src/gdal_fs.cpp

Get VSI file info.

Parameters
Parameter Type Description
filename string
True true

Return BigInt numbers. JavaScript numbers are safe for integers up to 2^53.

Throws Returns

function statAsync() src/gdal_fs.cpp

Get VSI file info.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
filename string
bigint false

Return BigInt numbers. JavaScript numbers are safe for integers up to 2^53.

callback callback < VSIStat >
Throws Returns

function statAsync() src/gdal_fs.cpp

Get VSI file info.

This is an asynchronous call. If its last argument is a function, then this function will be called on completion following the standard Node.js callback convection of `(error, result)`. The return value will be `undefined. The callback can be specified even if some optional arguments are omitted. Argument errors will throw, but runtime errors will be reported via the callback. If the last argument is not a callback the function will return a Promise that will resolve with the result. In this case all errors will result in a rejected Promise.

Parameters
Parameter Type Description
filename string
True true

Return BigInt numbers. JavaScript numbers are safe for integers up to 2^53.

callback callback < VSIStat >
Throws Returns


namespace vsimem src/gdal_memfile.cpp

File operations specific to in-memory /vsimem/ files.

function copy() src/gdal_memfile.cpp

Create an in-memory /vsimem/ file copying a Buffer . This method copies the Buffer into GDAL's own memory heap creating an in-memory file that can be freely extended by GDAL. gdal.vsimem.set is the better choice unless the file needs to be extended.

The file will stay in memory until it is deleted with gdal.vsimem.release .

Parameters
Parameter Type Description
data Buffer

A binary buffer containing the file data

filename string

A file name beginning with /vsimem/

Throws

function release() src/gdal_memfile.cpp

Delete and retrieve the contents of an in-memory /vsimem/ file. This is a very fast zero-copy operation. It does not block the event loop. If the file was created by vsimem.set , it will return a reference to the same Buffer that was used to create it. Otherwise it will construct a new Buffer object with the GDAL allocated buffer as its backing store.

!

The file must not be open or random memory corruption is possible with GDAL <= 3.3.1. GDAL >= 3.3.2 will gracefully fail further operations and this function will always be safe.

Parameters
Parameter Type Description
filename string

A file name beginning with /vsimem/

Throws Returns
Buffer

A binary buffer containing all the data


function set() src/gdal_memfile.cpp

Create an in-memory /vsimem/ file from a Buffer . This is a zero-copy operation - GDAL will read from the Buffer which will be protected by the GC even if it goes out of scope.

The file will stay in memory until it is deleted with gdal.vsimem.release .

The file will be in read-write mode, but GDAL won't be able to extend it as the allocated memory will be tied to the Buffer object. Use gdal.vsimem.copy to create an extendable copy.

Parameters
Parameter Type Description
data Buffer

A binary buffer containing the file data

filename string

A file name beginning with /vsimem/

Throws