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