AI-generated Key Takeaways
-
ee.Feature
objects represent geographic features with geometry and properties, and can be constructed from geometries, GeoJSON, or computed objects. -
Features can have an optional dictionary of properties to store metadata.
-
Feature IDs are determined by the
system:index
property, if present, or by theid
property as a fallback. -
The
ee.Feature
constructor provides a flexible way to create features with or without geometries and associated properties within Earth Engine. -
Simple features can be visualized on a map using
Map.addLayer
andMap.centerObject
in JavaScript or similar functions in Python usinggeemap
.
- An ee.Geometry.
- A GeoJSON Geometry.
- A GeoJSON Feature.
- A computed object: reinterpreted as a geometry if properties are specified, and as a feature if they aren't.
Usage | Returns |
---|---|
ee.Feature(geometry, properties) | Feature |
Argument | Type | Details |
---|---|---|
geometry | ComputedObject|Feature|Geometry|Object | A geometry or feature. |
properties | Object, optional | A dictionary of metadata properties. If the first parameter is a Feature (instead of a geometry), this is unused. |
Examples
Code Editor (JavaScript)
// Create the simplest possible feature. print(ee.Feature(null)); // Empty feature // Demonstrate how to set a feature's id. print(ee.Feature(null, {'id': 'yada'}).id()); // null print(ee.Feature(null, {'system:index': 'abc123'}).id()); // abc123 // The simplest possible feature with a geometry. var feature = ee.Feature(ee.Geometry.Point([-114.318, 38.985])); Map.addLayer(feature); Map.centerObject(feature, 10);
import ee import geemap.core as geemap
Colab (Python)
# Create the simplest possible feature. display(ee.Feature(None)) # Empty feature # Demonstrate how to set a feature's id. display(ee.Feature(None, {'id': 'yada'}).id()) # None display(ee.Feature(None, {'system:index': 'abc123'}).id()) # abc123 # The simplest possible feature with a geometry. feature = ee.Feature(ee.Geometry.Point([-114.318, 38.985])) m = geemap.Map() m.add_layer(feature) m.center_object(feature, 10) m