gdal.Feature
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);`
Table of Contents
Constructor
gdal.Feature
-
definition
Parameters:
-
definition
gdal.Layer | gdal.FeatureDefn
Methods
destroy
()
Releases the feature from memory.
equals
-
feature
Determines if the features are the same.
Parameters:
-
feature
gdal.Feature
Returns:
true
if the features are the same, false
if different
Returns the definition of a particular field at an index.
Parameters:
-
index
IntegerField index (0-based)
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 optionalArray 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 optionaltrue
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);`