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

getFieldDefn
(
  • index
)
gdal.FieldDefn

Returns the definition of a particular field at an index.

Parameters:

  • index Integer

    Field index (0-based)

Returns:

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] Array optional

    Array of the indices (integers) of the feature's fields stored at the corresponding index of the source feature's fields. A value of -1 should be used to ignore the source's field. The array should not be null and be as long as the number of fields in the source feature.

  • [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:

Attributes

defn

gdal.FeatureDefn readonly

fid

Number

fields

gdal.FeatureFields readonly