Show:

An encapsulation of a Layer's features.

Methods

add
(
  • feature
)

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

Parameters:

Example:

var feature = new gdal.Feature(layer);
feature.setGeometry(new gdal.Point(0, 1));
feature.fields.set('name', 'somestring');
layer.features.add(feature);`
addAsync
(
  • feature
  • callback=undefined
)
Promise

Adds a feature to the layer. The feature should be created using the current layer as the definition. Asynchronous version. If the last parameter is a callback, then this callback is called on completion and undefined is returned. All optional parameters before the callback can be omitted so the callback parameter can be at any position as long as it is the last parameter. Otherwise the function returns a Promise resolved with the result.

Parameters:

  • feature gdal.Feature
  • [callback=undefined] Callback optional

    standard Node.js (error, result) callback. It is always the last parameter and can be specified even if certain optional parameters are omitted. On error error is an Error object and result is undefined. On success error is null and result contains the result. The function returns a Promise when the callback is undefined. The return value is undefined when a callback is provided. Argument type errors are thrown synchronously even when a callback is provided. In Promise mode all errors result in a rejected Promise.

Returns:

Promise

Example:

var feature = new gdal.Feature(layer);
feature.setGeometry(new gdal.Point(0, 1));
feature.fields.set('name', 'somestring');
await layer.features.addAsync(feature);`
count
(
  • force=true
)
Number

Returns the number of features in the layer.

Parameters:

  • [force=true] Boolean optional

Returns:

Number:

number of features in the layer.

countAsync
(
  • force=true
  • callback=undefined
)
Promise

Returns the number of features in the layer. Asynchronous version. If the last parameter is a callback, then this callback is called on completion and undefined is returned. All optional parameters before the callback can be omitted so the callback parameter can be at any position as long as it is the last parameter. Otherwise the function returns a Promise resolved with the result.

Parameters:

  • [force=true] Boolean optional
  • [callback=undefined] Callback optional

    standard Node.js (error, result) callback. It is always the last parameter and can be specified even if certain optional parameters are omitted. On error error is an Error object and result is undefined. On success error is null and result contains the result. The function returns a Promise when the callback is undefined. The return value is undefined when a callback is provided. Argument type errors are thrown synchronously even when a callback is provided. In Promise mode all errors result in a rejected Promise.

Returns:

Promise:

number of features in the layer.

first () gdal.Feature

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

Returns:

firstAsync
(
  • callback=undefined
)
Promise

Resets the feature pointer used by next() and returns the first feature in the layer. Asynchronous version. If the last parameter is a callback, then this callback is called on completion and undefined is returned. All optional parameters before the callback can be omitted so the callback parameter can be at any position as long as it is the last parameter. Otherwise the function returns a Promise resolved with the result.

Parameters:

  • [callback=undefined] callback optional

    standard Node.js (error, result) callback. It is always the last parameter and can be specified even if certain optional parameters are omitted. On error error is an Error object and result is undefined. On success error is null and result contains the result. The function returns a Promise when the callback is undefined. The return value is undefined when a callback is provided. Argument type errors are thrown synchronously even when a callback is provided. In Promise mode all errors result in a rejected Promise.

Returns:

Promise
forEach
(
  • callback
)

Defined in lib/iterators.js:82

Iterates through all features using a callback function.

Parameters:

  • callback forEachCb

    The callback to be called with each Feature

Example:

layer.features.forEach(function(feature, i) { ... });`
get
(
  • id
)
gdal.Feature

Fetch a feature by its identifier.

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

Parameters:

  • id Number

    The feature ID of the feature to read.

Returns:

getAsync
(
  • id
  • callback=undefined
)
Promise

Fetch a feature by its identifier.

Important: The id argument is not an index. In most cases it will be zero-based, but in some cases it will not. If iterating, it's best to use the next() method. Asynchronous version. If the last parameter is a callback, then this callback is called on completion and undefined is returned. All optional parameters before the callback can be omitted so the callback parameter can be at any position as long as it is the last parameter. Otherwise the function returns a Promise resolved with the result.

Parameters:

  • id Number

    The feature ID of the feature to read.

  • [callback=undefined] callback optional

    standard Node.js (error, result) callback. It is always the last parameter and can be specified even if certain optional parameters are omitted. On error error is an Error object and result is undefined. On success error is null and result contains the result. The function returns a Promise when the callback is undefined. The return value is undefined when a callback is provided. Argument type errors are thrown synchronously even when a callback is provided. In Promise mode all errors result in a rejected Promise.

Returns:

Promise
map<U>
(
  • callback
)
U[]

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

Parameters:

  • callback mapCb

    The callback to be called with each Feature

Returns:

U[]

Example:

var result = layer.features.map(function(array, i) {
    return value;
});`
next () gdal.Feature

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

Returns:

Example:

while (feature = layer.features.next()) { ... }`
nextAsync
(
  • callback=undefined
)
Promise

Returns the next feature in the layer. Returns null if no more features. Asynchronous version. If the last parameter is a callback, then this callback is called on completion and undefined is returned. All optional parameters before the callback can be omitted so the callback parameter can be at any position as long as it is the last parameter. Otherwise the function returns a Promise resolved with the result.

Parameters:

  • [callback=undefined] callback optional

    standard Node.js (error, result) callback. It is always the last parameter and can be specified even if certain optional parameters are omitted. On error error is an Error object and result is undefined. On success error is null and result contains the result. The function returns a Promise when the callback is undefined. The return value is undefined when a callback is provided. Argument type errors are thrown synchronously even when a callback is provided. In Promise mode all errors result in a rejected Promise.

Returns:

Promise

Example:

while (feature = await layer.features.nextAsync()) { ... }`
remove
(
  • id
)

Removes a feature from the layer.

Parameters:

  • id Number
removeAsync
(
  • id
  • callback=undefined
)
Promise

Removes a feature from the layer. Asynchronous version. If the last parameter is a callback, then this callback is called on completion and undefined is returned. All optional parameters before the callback can be omitted so the callback parameter can be at any position as long as it is the last parameter. Otherwise the function returns a Promise resolved with the result.

Parameters:

  • id Number
  • [callback=undefined] Callback optional

    standard Node.js (error, result) callback. It is always the last parameter and can be specified even if certain optional parameters are omitted. On error error is an Error object and result is undefined. On success error is null and result contains the result. The function returns a Promise when the callback is undefined. The return value is undefined when a callback is provided. Argument type errors are thrown synchronously even when a callback is provided. In Promise mode all errors result in a rejected Promise.

Returns:

Promise
set
(
  • feature
)

Sets a feature in the layer.

Parameters:

set
(
  • id
  • feature
)

Sets a feature in the layer.

Parameters:

setAsync
(
  • id
  • feature
  • callback=undefined
)
Promise

Sets a feature in the layer. Asynchronous version. If the last parameter is a callback, then this callback is called on completion and undefined is returned. All optional parameters before the callback can be omitted so the callback parameter can be at any position as long as it is the last parameter. Otherwise the function returns a Promise resolved with the result.

Parameters:

  • id Number
  • feature gdal.Feature
  • [callback=undefined] callback optional

    standard Node.js (error, result) callback. It is always the last parameter and can be specified even if certain optional parameters are omitted. On error error is an Error object and result is undefined. On success error is null and result contains the result. The function returns a Promise when the callback is undefined. The return value is undefined when a callback is provided. Argument type errors are thrown synchronously even when a callback is provided. In Promise mode all errors result in a rejected Promise.

Returns:

Promise
Symbol.asyncIterator ()

Iterates through all features using an async iterator

Example:

for await (const feature of layer.features) {
}`
Symbol.iterator ()

Iterates through all features using an iterator

Example:

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

Attributes

layer

gdal.Layer

Parent layer