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.
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:
|
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
|
y_size |
number
| undefined
|
Used when creating a raster dataset with the
|
band_count |
number
| undefined
|
Used when creating a raster dataset with the
|
data_type |
string
| undefined
|
Used when creating a raster dataset with the
|
creation_options |
Array
<
string
>
| object
| undefined
|
Used when creating a dataset with the
|
Error
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.
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:
|
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
|
y_size |
number
| undefined
|
Used when creating a raster dataset with the
|
band_count |
number
| undefined
|
Used when creating a raster dataset with the
|
data_type |
string
| undefined
|
Used when creating a raster dataset with the
|
creation_options |
Array
<
string
>
| object
| undefined
|
Used when creating a dataset with the
|
callback |
callback
<
Dataset
>
|
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
Parameter | Type | Description |
---|---|---|
path |
string
| Buffer
|
Path to dataset or in-memory Buffer to open |
callback |
callback
<
Dataset
>
|
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;
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:
Examplevar 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.
Examplevar 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
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.
ThrowssrsAsync : 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.
Throwsfunction buildOverviews() src/gdal_dataset.cpp
Builds dataset overviews.
Parameter | Type | Description |
---|---|---|
resampling |
string
|
|
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 |
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.
Parameter | Type | Description |
---|---|---|
resampling |
string
|
|
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
>
|
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.
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
|
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.
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
|
callback |
callback
<
Layer
>
|
function flush() src/gdal_dataset.cpp
Flushes all changes to disk.
Throwsfunction 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.
Parameter | Type | Description |
---|---|---|
callback |
callback
<
void
>
|
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.
Parameter | Type | Description |
---|---|---|
domain |
string
| undefined
|
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.
Parameter | Type | Description |
---|---|---|
domain |
string
| undefined
|
|
callback |
callback
<
void
>
|
Promise
<
any
>
function setGCPs() src/gdal_dataset.cpp
Sets GCPs.
Parameter | Type | Description |
---|---|---|
gcps |
Array
<
object
>
|
|
projection |
string
| undefined
|
function setMetadata() src/gdal_dataset.cpp
Set metadata. Can return a warning (false) for formats not supporting persistent metadata.
Parameter | Type | Description |
---|---|---|
metadata |
object
| Array
<
string
>
|
|
domain |
string
| undefined
|
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.
Parameter | Type | Description |
---|---|---|
metadata |
object
| Array
<
string
>
|
|
domain |
string
| undefined
|
|
callback |
callback
<
boolean
>
|
Promise
<
boolean
>
function testCapability() src/gdal_dataset.cpp
Determines if the dataset supports the indicated operation.
Parameter | Type | Description |
---|---|---|
capability |
string
|
boolean
class DatasetBands src/collections/dataset_bands.cpp
An encapsulation of a Dataset raster bands.
Examplevar bands = dataset.bands;
function forEach() lib/iterators.js
Iterates through all bands using a callback function. Note: GDAL band indexes start at 1, not 0.
Parameter | Type | Description |
---|---|---|
callback |
forEachCb
<
RasterBand
>
|
The callback to be called with each RasterBand |
dataset.bands.forEach(function(band, i) { ... });
function getEnvelope() lib/gdal.js
Returns a Envelope object for the raster bands
Returns Exampleconst extent = dataset.getEnvelope()
`
function Symbol.asyncIterator() : RasterBand lib/iterators.js
Iterates through all bands using an async iterator
Examplefor await (const band of dataset.bands) {
}
function Symbol.iterator() : RasterBand lib/iterators.js
Iterates through all bands using an iterator
Examplefor (const band of dataset.bands) {
}
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.
Parameter | Type | Description |
---|---|---|
callback |
callback
<
number
>
|
Promise
<
number
>
function create() src/collections/dataset_bands.cpp
Adds a new band.
Parameter | Type | Description |
---|---|---|
dataType |
string
|
Type of band ( see GDT constants ) |
options |
object
| Array
<
string
>
| undefined
|
Creation options |
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.
Parameter | Type | Description |
---|---|---|
dataType |
string
|
Type of band ( see GDT constants ) |
options |
object
| Array
<
string
>
| undefined
|
Creation options |
callback |
callback
<
RasterBand
>
|
Promise
<
RasterBand
>
function get() src/collections/dataset_bands.cpp
Returns the band with the given ID.
Parameter | Type | Description |
---|---|---|
id |
number
|
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.
Parameter | Type | Description |
---|---|---|
id |
number
|
|
callback |
callback
<
RasterBand
>
|
Promise
<
RasterBand
>
function map() lib/default_iterators.js
Iterates through raster bands using a callback function and builds an array of the returned values.
Parameter | Type | Description |
---|---|---|
callback |
mapCb
<
RasterBand
, U
>
|
The callback to be called with each RasterBand |
Array
<
U
>
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.
description : string src/gdal_driver.cpp
function copyFiles() src/gdal_driver.cpp
Copy the files of a dataset.
Parameter | Type | Description |
---|---|---|
name_old |
string
|
New name for the dataset. |
name_new |
string
|
Old name of the dataset. |
function create() src/gdal_driver.cpp
Create a new dataset with this driver.
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 |
function createAsync() src/gdal_driver.cpp
Asynchronously create a new dataset with this driver.
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
>
|
function createCopy() src/gdal_driver.cpp
Create a copy of a dataset.
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 |
function createCopyAsync() src/gdal_driver.cpp
Asynchronously create a copy of a dataset.
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
>
|
function deleteDataset() src/gdal_driver.cpp
Parameter | Type | Description |
---|---|---|
filename |
string
|
function getMetadata() src/gdal_driver.cpp
Returns metadata about the driver.
Parameter | Type | Description |
---|---|---|
domain |
string
| undefined
|
any
function open() src/gdal_driver.cpp
Opens a dataset.
Parameter | Type | Description |
---|---|---|
path |
string
|
|
mode |
string
|
The mode to use to open the file:
|
options |
StringOptions
| undefined
|
Driver-specific open options |
function openAsync() src/gdal_driver.cpp
Opens a dataset.
Parameter | Type | Description |
---|---|---|
path |
string
|
|
mode |
string
|
The mode to use to open the file:
|
options |
StringOptions
| undefined
|
Driver-specific open options |
callback |
callback
<
Dataset
>
|
function rename() src/gdal_driver.cpp
Renames the dataset.
Parameter | Type | Description |
---|---|---|
new_name |
string
|
New name for the dataset. |
old_name |
string
|
Old name of the dataset. |
class GDALDrivers src/collections/gdal_drivers.cpp
An collection of all Driver registered with GDAL.
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.
Parameter | Type | Description |
---|---|---|
callback |
forEachCb
<
Driver
>
|
The callback to be called with each Driver |
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.
Parameter | Type | Description |
---|---|---|
index |
number
| string
|
0-based index or driver name |
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.
Parameter | Type | Description |
---|---|---|
callback |
mapCb
<
Driver
, U
>
|
The callback to be called with each Driver |
Array
<
U
>
var result = gdal.drivers.map(function(array, i) {
return value;
});
function prototype() : Driver lib/default_iterators.js
Iterates through all drivers using an iterator
Examplefor (const array of gdal.drivers) {
}
class RasterBand src/gdal_rasterband.cpp
A single raster band (or channel).
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 Returnsfunction 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.
Parameter | Type | Description |
---|---|---|
allow_approximation |
boolean
|
If
|
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.
Parameter | Type | Description |
---|---|---|
allow_approximation |
boolean
|
If
|
callback |
callback
<
stats
>
|
function createMaskBand() src/gdal_rasterband.cpp
Adds a mask band to the current band.
Parameter | Type | Description |
---|---|---|
flags |
number
|
Mask flags |
function fill() src/gdal_rasterband.cpp
Fill this band with a constant value.
Parameter | Type | Description |
---|---|---|
real_value |
number
|
|
imaginary_value |
number
| undefined
|
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.
Parameter | Type | Description |
---|---|---|
real_value |
number
|
|
imaginary_value |
number
| undefined
|
|
callback |
callback
<
void
>
|
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.
Parameter | Type | Description |
---|---|---|
callback |
callback
<
void
>
|
Promise
<
void
>
function getMaskBand() src/gdal_rasterband.cpp
Return the mask band associated with the band.
Returnsfunction 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.
Parameter | Type | Description |
---|---|---|
domain |
string
| undefined
|
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.
Parameter | Type | Description |
---|---|---|
domain |
string
| undefined
|
|
callback |
callback
<
any
>
|
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.
Parameter | Type | Description |
---|---|---|
allow_approximation |
boolean
|
If
|
force |
boolean
|
If
|
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.
Parameter | Type | Description |
---|---|---|
metadata |
object
| Array
<
string
>
|
|
domain |
string
| undefined
|
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.
Parameter | Type | Description |
---|---|---|
metadata |
object
| Array
<
string
>
|
|
domain |
string
| undefined
|
|
callback |
callback
<
boolean
>
|
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.
Parameter | Type | Description |
---|---|---|
min |
number
|
|
max |
number
|
|
mean |
number
|
|
std_dev |
number
|
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
Exampleconst 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);
typedef ReadOptions : object src/collections/rasterband_pixels.cpp
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
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
|
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.
Parameter | Type | Description |
---|---|---|
x |
number
|
|
y |
number
|
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.
Parameter | Type | Description |
---|---|---|
x |
number
|
|
y |
number
|
|
callback |
callback
<
xyz
>
|
function createReadStream() lib/readable.js
create a Readable stream from a raster band
Parameter | Type | Description |
---|---|---|
options |
RasterReadableOptions
| undefined
|
function createWriteStream() lib/writable.js
create a Writable stream from a raster band
Parameter | Type | Description |
---|---|---|
options |
RasterWritableOptions
| undefined
|
function get() src/collections/rasterband_pixels.cpp
Returns the value at the x, y coordinate.
Parameter | Type | Description |
---|---|---|
x |
number
|
|
y |
number
|
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.
Parameter | Type | Description |
---|---|---|
x |
number
|
|
y |
number
|
|
callback |
callback
<
number
>
|
Promise
<
number
>
function read() src/collections/rasterband_pixels.cpp
Reads a region of pixels.
Parameter | Type | Description |
---|---|---|
x |
number
|
|
y |
number
|
|
width |
number
|
|
height |
number
|
|
data |
TypedArray
| undefined
|
The
|
options |
ReadOptions
| undefined
|
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.
Parameter | Type | Description |
---|---|---|
x |
number
|
|
y |
number
|
|
width |
number
|
the width |
height |
number
|
|
data |
TypedArray
| undefined
|
The
|
options |
ReadOptions
| undefined
|
|
callback |
callback
<
TypedArray
>
|
Promise
<
TypedArray
>
A
TypedArray
of values.
function readBlock() src/collections/rasterband_pixels.cpp
Reads a block of pixels.
Parameter | Type | Description |
---|---|---|
x |
number
|
|
y |
number
|
|
data |
TypedArray
| undefined
|
The
|
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.
Parameter | Type | Description |
---|---|---|
x |
number
|
|
y |
number
|
|
data |
TypedArray
| undefined
|
The
|
callback |
callback
<
TypedArray
>
|
Promise
<
TypedArray
>
A
TypedArray
of values.
function set() src/collections/rasterband_pixels.cpp
Sets the value at the x, y coordinate.
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.
Parameter | Type | Description |
---|---|---|
x |
number
|
|
y |
number
|
|
value |
number
|
|
callback |
callback
<
void
>
|
Promise
<
void
>
function write() src/collections/rasterband_pixels.cpp
Writes a region of pixels.
Parameter | Type | Description |
---|---|---|
x |
number
|
|
y |
number
|
|
width |
number
|
|
height |
number
|
|
data |
TypedArray
| undefined
|
The
|
options |
WriteOptions
| undefined
|
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.
Parameter | Type | Description |
---|---|---|
x |
number
|
|
y |
number
|
|
width |
number
|
|
height |
number
|
|
data |
TypedArray
| undefined
|
The
|
options |
WriteOptions
| undefined
|
|
callback |
callback
<
void
>
|
Promise
<
void
>
function writeBlock() src/collections/rasterband_pixels.cpp
Writes a block of pixels.
Parameter | Type | Description |
---|---|---|
x |
number
|
|
y |
number
|
|
data |
TypedArray
|
The
|
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.
Parameter | Type | Description |
---|---|---|
x |
number
|
|
y |
number
|
|
data |
TypedArray
|
The
|
callback |
callback
<
void
>
|
Promise
<
void
>
class RasterBandOverviews src/collections/rasterband_overviews.cpp
An encapsulation of a RasterBand overview functionality.
function asyncIterator() : RasterBand lib/default_iterators.js
Iterates through all overviews using an async iterator
Examplefor 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.
Parameter | Type | Description |
---|---|---|
callback |
callback
<
number
>
|
Promise
<
number
>
function forEach() lib/default_iterators.js
Iterates through all overviews using a callback function.
Parameter | Type | Description |
---|---|---|
callback |
forEachCb
<
RasterBand
>
|
The callback to be called with each RasterBand |
band.overviews.forEach(function(array, i) { ... });
function get() src/collections/rasterband_overviews.cpp
Fetches the overview at the provided index.
Parameter | Type | Description |
---|---|---|
index |
number
|
0-based index |
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.
Parameter | Type | Description |
---|---|---|
index |
number
|
0-based index |
callback |
callback
<
RasterBand
>
|
Promise
<
RasterBand
>
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.
Parameter | Type | Description |
---|---|---|
samples |
number
|
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.
Parameter | Type | Description |
---|---|---|
samples |
number
|
|
callback |
callback
<
RasterBand
>
|
Promise
<
RasterBand
>
function map() lib/default_iterators.js
Iterates through overviews using a callback function and builds an array of the returned values.
Parameter | Type | Description |
---|---|---|
callback |
mapCb
<
RasterBand
, U
>
|
The callback to be called with each RasterBand |
Array
<
U
>
var result = band.overviews.map(function(array, i) {
return value;
});
function prototype() : RasterBand lib/default_iterators.js
Iterates through all overviews using an iterator
Examplefor (const array of band.overviews) {
}
class ColorTable src/collections/colortable.cpp
An encapsulation of a RasterBand color table.
Parameter | Type | Description |
---|---|---|
interpretation |
string
|
palette interpretation |
var colorTable = band.colorTable;
band.colorTable = new gdal.ColorTable(gdal.GPI_RGB);
typedef Color : object src/collections/colortable.cpp
Property | Type | Description |
---|---|---|
c1
|
number
|
|
c2
|
number
|
|
c3
|
number
|
|
c4
|
number
|
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.
Returnsfunction 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.
Parameter | Type | Description |
---|---|---|
callback |
forEachCb
<
Color
>
|
The callback to be called with each Color |
band.colorTable.forEach(function(array, i) { ... });
function get() src/collections/colortable.cpp
Returns the color with the given ID.
Parameter | Type | Description |
---|---|---|
index |
number
|
function isSame() src/collections/colortable.cpp
Compares two ColorTable objects for equality.
Parameter | Type | Description |
---|---|---|
other |
ColorTable
|
boolean
function map() lib/default_iterators.js
Iterates through color entries using a callback function and builds an array of the returned values.
Parameter | Type | Description |
---|---|---|
callback |
mapCb
<
Color
, U
>
|
The callback to be called with each Color |
Array
<
U
>
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
Examplefor (const array of band.colorTable) {
}
function ramp() src/collections/colortable.cpp
Creates a color ramp from one color entry to another.
Parameter | Type | Description |
---|---|---|
start_index |
number
|
|
start_color |
Color
|
|
end_index |
number
|
|
end_color |
Color
|
number
total number of color entries
function set() src/collections/colortable.cpp
Sets the color entry with the given ID.
Parameter | Type | Description |
---|---|---|
index |
number
|
|
color |
Color
|
void
class Layer src/gdal_layer.cpp
A representation of a layer of simple vector features, with access methods.
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.
Throwsfunction 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.
Parameter | Type | Description |
---|---|---|
callback |
callback
<
void
>
|
Promise
<
void
>
function getExtent() src/gdal_layer.cpp
Fetch the extent of this layer.
Parameter | Type | Description |
---|---|---|
force |
boolean
|
Envelope
Bounding envelope
function getSpatialFilter() src/gdal_layer.cpp
This method returns the current spatial filter for this layer.
Throws Returnsfunction 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.
Parameter | Type | Description |
---|---|---|
filter |
string
|
null
|
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.
Parameter | Type | Description |
---|---|---|
filter |
Geometry
|
null
|
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.
Parameter | Type | Description |
---|---|---|
minxX |
number
|
|
minyY |
number
|
|
maxX |
number
|
|
maxY |
number
|
layer.setSpatialFilter(minX, minY, maxX, maxY);
function testCapability() src/gdal_layer.cpp
Determines if the dataset supports the indicated operation.
Parameter | Type | Description |
---|---|---|
capability |
string
|
(see capability list |
boolean
class DatasetLayers src/collections/dataset_layers.cpp
An encapsulation of a Dataset vector layers.
Examplevar layers = dataset.layers;
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
Examplefor await (const array of dataset.layers) {
}
function copy() src/collections/dataset_layers.cpp
Copies a layer.
Parameter | Type | Description |
---|---|---|
src_lyr_name |
Layer
|
|
dst_lyr_name |
string
|
|
options |
object
| Array
<
string
>
|
layer creation options |
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.
Parameter | Type | Description |
---|---|---|
src_lyr_name |
Layer
|
|
dst_lyr_name |
string
|
|
options |
object
| Array
<
string
>
|
layer creation options |
callback |
callback
<
Layer
>
|
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.
Parameter | Type | Description |
---|---|---|
callback |
callback
<
number
>
|
Promise
<
number
>
function create() src/collections/dataset_layers.cpp
Adds a new layer.
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 |
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.
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
>
|
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.
Parameter | Type | Description |
---|---|---|
callback |
forEachCb
<
Layer
>
|
The callback to be called with each Layer |
dataset.layers.forEach(function(array, i) { ... });
function get() src/collections/dataset_layers.cpp
Returns the layer with the given name or identifier.
Parameter | Type | Description |
---|---|---|
key |
string
| number
|
Layer name or ID. |
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.
Parameter | Type | Description |
---|---|---|
key |
string
| number
|
Layer name or ID. |
callback |
callback
<
Layer
>
|
function map() lib/default_iterators.js
Iterates through layers using a callback function and builds an array of the returned values.
Parameter | Type | Description |
---|---|---|
callback |
mapCb
<
Layer
, U
>
|
The callback to be called with each Layer |
Array
<
U
>
var result = dataset.layers.map(function(array, i) {
return value;
});
function prototype() : Layer lib/default_iterators.js
Iterates through all layers using an iterator
Examplefor (const array of dataset.layers) {
}
function remove() src/collections/dataset_layers.cpp
Removes a layer.
Parameter | Type | Description |
---|---|---|
index |
number
|
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.
Parameter | Type | Description |
---|---|---|
index |
number
|
|
callback |
callback
<
void
>
|
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.
Parameter | Type | Description |
---|---|---|
wkt |
string
| undefined
|
function autoIdentifyEPSG() src/gdal_spatial_reference.cpp
Set EPSG authority info if possible.
Throwsfunction clone() src/gdal_spatial_reference.cpp
Clones the spatial reference.
Returnsfunction cloneGeogCS() src/gdal_spatial_reference.cpp
Make a duplicate of the GEOGCS node of this OGRSpatialReference object.
Returnsfunction 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.
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.
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).
Parameter | Type | Description |
---|---|---|
input |
string
|
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.
Parameter | Type | Description |
---|---|---|
input |
string
|
|
callback |
callback
<
SpatialReference
>
|
function fromEPSG() src/gdal_spatial_reference.cpp
Initialize from EPSG GCS or PCS code.
Parameter | Type | Description |
---|---|---|
input |
number
|
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).
Parameter | Type | Description |
---|---|---|
input |
number
|
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.
Parameter | Type | Description |
---|---|---|
input |
object
| Array
<
string
>
|
function fromMICoordSys() src/gdal_spatial_reference.cpp
Initialize from a Mapinfo style CoordSys definition.
Parameter | Type | Description |
---|---|---|
input |
string
|
function fromProj4() src/gdal_spatial_reference.cpp
Creates a spatial reference from a Proj.4 string.
Parameter | Type | Description |
---|---|---|
input |
string
|
function fromURL() src/gdal_spatial_reference.cpp
Initialize spatial reference from a URL.
This method will download the spatial reference from the given URL.
Parameter | Type | Description |
---|---|---|
url |
string
|
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.
Parameter | Type | Description |
---|---|---|
url |
string
|
|
callback |
callback
<
SpatialReference
>
|
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).
Parameter | Type | Description |
---|---|---|
input |
string
|
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.
Parameter | Type | Description |
---|---|---|
input |
string
|
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.
Parameter | Type | Description |
---|---|---|
input |
string
|
|
callback |
callback
<
SpatialReference
>
|
function fromWKT() src/gdal_spatial_reference.cpp
Creates a spatial reference from a WKT string.
Parameter | Type | Description |
---|---|---|
wkt |
string
|
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.
Parameter | Type | Description |
---|---|---|
input |
string
|
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).
Parameter | Type | Description |
---|---|---|
input |
string
|
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.
Parameter | Type | Description |
---|---|---|
node_name |
string
|
|
attr_index |
number
|
string
function getAuthorityCode() src/gdal_spatial_reference.cpp
Get the authority code for a node.
Parameter | Type | Description |
---|---|---|
target_key |
string
|
null
| undefined
|
The partial or complete path to the node to get an authority from. ie.
|
string
function getAuthorityName() src/gdal_spatial_reference.cpp
Get the authority name for a node. The most common authority is "EPSG".
Parameter | Type | Description |
---|---|---|
target_key |
string
|
null
| undefined
|
The partial or complete path to the node to get an authority from. ie.
|
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?
Parameter | Type | Description |
---|---|---|
srs |
SpatialReference
|
boolean
function isSameGeogCS() src/gdal_spatial_reference.cpp
Do the GeogCS'es match?
Parameter | Type | Description |
---|---|---|
srs |
SpatialReference
|
boolean
function isSameVertCS() src/gdal_spatial_reference.cpp
Do the VertCS'es match?
Parameter | Type | Description |
---|---|---|
srs |
SpatialReference
|
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.
Throwsfunction morphToESRI() src/gdal_spatial_reference.cpp
Convert in place to ESRI WKT format.
Throwsfunction setWellKnownGeogCS() src/gdal_spatial_reference.cpp
Set a GeogCS based on well known name.
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.
Parameter | Type | Description |
---|---|---|
simplify |
boolean
|
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.
Parameter | Type | Description |
---|---|---|
source |
SpatialReference
|
|
target |
SpatialReference
| Dataset
|
If a raster Dataset, the conversion will represent a conversion to pixel coordinates. |
function transformPoint() src/gdal_coordinate_transformation.cpp
Transform point from source to destination space.
Parameter | Type | Description |
---|---|---|
x |
number
|
|
y |
number
|
|
z |
number
| undefined
|
pt = transform.transformPoint(0, 0, 0);
function transformPoint() src/gdal_coordinate_transformation.cpp
Transform point from source to destination space.
Parameter | Type | Description |
---|---|---|
point |
xyz
|
pt = transform.transformPoint({x: 0, y: 0, z: 0});
Features
Classes for working with vector features
class LayerFields src/collections/layer_fields.cpp
function fromJSON() lib/gdal.js
Creates a LayerFields instance from an object of keys and values.
Parameter | Type | Description |
---|---|---|
object |
object
|
|
approx_ok |
boolean
|
function fromObject() lib/gdal.js
Creates a LayerFields instance from an object of keys and values.
Parameter | Type | Description |
---|---|---|
object |
Record
<
string
, any
>
|
|
approx_ok |
boolean
|
layer : Layer src/collections/layer_fields.cpp
Returns the parent layer.
function add() src/collections/layer_fields.cpp
Adds field(s).
Parameter | Type | Description |
---|---|---|
defs |
FieldDefn
| Array
<
FieldDefn
>
|
A field definition, or array of field definitions. |
approx |
boolean
|
function asyncIterator() : FieldDefn lib/default_iterators.js
Iterates through all field definitions using an async iterator
Examplefor 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.
Parameter | Type | Description |
---|---|---|
callback |
forEachCb
<
FieldDefn
>
|
The callback to be called with each FieldDefn |
layer.fields.forEach(function(array, i) { ... });
function get() src/collections/layer_fields.cpp
Returns a field definition.
Parameter | Type | Description |
---|---|---|
field |
string
| number
|
Field name or index (0-based) |
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.
Parameter | Type | Description |
---|---|---|
field |
string
|
number
Field index, or -1 if the field doesn't exist