- A string: assumed to be the name of a collection.
- A single geometry.
- A single feature.
- A list of features.
- A GeoJSON FeatureCollection
- A computed object: reinterpreted as a collection.
Usage | Returns |
---|---|
ee.FeatureCollection(args, column) | FeatureCollection |
Argument | Type | Details |
---|---|---|
args | ComputedObject|Feature|FeatureCollection|Geometry|List | The constructor arguments. |
column | String, optional | The name of the geometry column to use. Only useful when working with a named collection. |
Examples
Code Editor (JavaScript)
// FeatureCollection from a string (collection name). Note that this only works // with client-side strings, it won't accept computed, server-side strings. var collectionName = 'WRI/GPPD/power_plants'; var collectionNameFc = ee.FeatureCollection(collectionName); print('FeatureCollection from a string', collectionNameFc.limit(5)); // FeatureCollection from a single geometry. var singleGeometry = ee.Geometry.Point(-62.54, -27.32); var singleGeometryFc = ee.FeatureCollection(singleGeometry); print('FeatureCollection from a single geometry', singleGeometryFc); // FeatureCollection from a single feature. var singleFeature = ee.Feature(ee.Geometry.Point(-62.54, -27.32), {key: 'val'}); var singleFeatureFc = ee.FeatureCollection(singleFeature); print('FeatureCollection from a single feature', singleFeatureFc); // FeatureCollection from a list of features. var listOfFeatures = [ ee.Feature(ee.Geometry.Point(-62.54, -27.32), {key: 'val1'}), ee.Feature(ee.Geometry.Point(-69.18, -10.64), {key: 'val2'}), ee.Feature(ee.Geometry.Point(-45.98, -18.09), {key: 'val3'}) ]; var listOfFeaturesFc = ee.FeatureCollection(listOfFeatures); print('FeatureCollection from a list of features', listOfFeaturesFc); // FeatureCollection from GeoJSON. var geojson = { "type": "FeatureCollection", "columns": { "key": "String", "system:index": "String" }, "features": [ { "type": "Feature", "geometry": { "type": "Point", "coordinates": [ -62.54, -27.32 ] }, "id": "0", "properties": { "key": "val1" } } ] }; var geojsonFc = ee.FeatureCollection(geojson); print('FeatureCollection from GeoJSON', geojsonFc);