Show:

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

//create layer and specify geometry type
var layer = dataset.layers.create('mylayer', null, gdal.Point);

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

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

Constructor

gdal.Feature
(
  • definition
)

Parameters:

Methods

clone () gdal.Feature

Clones the feature.

Returns:

destroy ()

Releases the feature from memory.

equals
(
  • feature
)
Boolean

Determines if the features are the same.

Parameters:

Returns:

Boolean:

true if the features are the same, false if different

getGeometry () gdal.Geometry

Returns the geometry of the feature.

Returns:

setFrom
(
  • feature
  • index_map
  • forgiving=true
)

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

Parameters:

  • feature gdal.Feature
  • [index_map] Number[] optional

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

  • [forgiving=true] Boolean optional

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

Example:

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

Sets the feature's geometry.

Parameters:

  • geometry gdal.Geometry | Null

    new geometry or null to clear the field

Attributes

defn

gdal.FeatureDefn readonly

fid

Number

fields

gdal.FeatureFields readonly