🌐
Introduction to Google Earth Engine
  • Google Earth Engine
  • What is Google Earth Engine?
  • How to Use Google Earth Engine
    • GEE Interface Platforms
    • Data Catalog
    • Using the Code Editor
      • Adding Data
      • Objects and Methods
        • ee.Image
        • ee.ImageCollection
        • ee.Geometry
        • ee.Feature and FeatureCollection
      • Image Classification
      • Data Visualisation
  • Useful Resources
Powered by GitBook
On this page

Was this helpful?

  1. How to Use Google Earth Engine
  2. Using the Code Editor
  3. Objects and Methods

ee.Feature and FeatureCollection

Features are constructed using the following notation:

ee.Feature(geomtery, properties)

A FeatureCollection can be one or more "arguments" such as:

  • a string

  • a single geometry

  • a Feature

  • a list of Features

  • a GeoJSON FeatureCollection

The notation is:

ee.FeatureCollection(args, column)

// 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);

Previousee.GeometryNextImage Classification

Last updated 3 years ago

Was this helpful?