Skip to content

Hello Feature Collection

Introduction

The videos below introduce geometry and feature objects in Google Earth Engine. They walk you through how to import a table as an asset, how to construct a feature from scratch in the Code Editor, and how to convert vector into raster in Earth Engine.


Start a new script

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//  Hello Feature Collection
//
//  Jeff Howarth 
//  Geography 251
//
//  Oct 1, 2023
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Import a table as an Asset


Load Feature Collection from String

graph LR
  method["ee.FeatureCollection.()"] --> output>output\n\nFEATURE COLLECTION];
  arg_att([pathname\n\nSTRING]) --> method

  style method fill:#ADD8E6,stroke-width:0px
  style output fill:#E1C3E6,stroke-width:0px
  style arg_att fill:#DCDCDC,stroke-width:0px
// --------------------------------------------------------------------------
//  Load Feature Collection from String (collection name). 
//
//  Updated: 9/30/23
// --------------------------------------------------------------------------

var hello_pond ;

print(
  'HELLO FEATURE COLLECTION:',
  hello_pond,
  hello_pond.size(),
  hello_pond.first()
  )
;

Center map on Object

// --------------------------------------------------------------------------
//  Center Map on Object.
//
//  Updated: 9/30/23
// -------------------------------------------------------------------------- 

Map.centerObject();
Map.setOptions();

Add Feature Collection as Map Layer

// --------------------------------------------------------------------------
//  Add Feature Collection as Map Layer.
//
//  Updated: 9/30/23
// --------------------------------------------------------------------------

Map.addLayer();

Create a geometry

// --------------------------------------------------------------------------
//  Create a Geometry.
//
//  Updated: 9/30/23
// --------------------------------------------------------------------------

print(
 'Pond Geometry:',
  geometry
  )
;

Construct a feature

graph LR
  method["ee.Feature()"] --> output>output\n\nFEATURE];
  arg_geom([GEOMETRY]) --> method;
  arg_att([attributes\n\nDICTIONARY]) --> method;

  style method fill:#ADD8E6,stroke-width:0px
  style output fill:#E1C3E6,stroke-width:0px
  style arg_geom fill:#E1C3E6,stroke-width:0px
  style arg_att fill:#DCDCDC,stroke-width:0px
// --------------------------------------------------------------------------
//  Construct a Feature.
//
//  Updated: 9/30/23
// --------------------------------------------------------------------------

 var pond_attributes ;

 var pond_feature ;

 print(
   "HELLO POND FEATURE:",
   "geometry:", geometry,
   "attributes:", pond_attributes,
   "feature:", pond_feature
   )
  ;

 Map.addLayer();

Convert feature collection into an image

graph LR
  input[/input\n\nFEATURE COLLECTION/] --> method[".reduceToImage()"]
  method --> output>output\n\nIMAGE];
  arg_att1([property key\n\nLIST]) --> method;
  arg_att2(["ee.Reducer()"]) --> method;

  style input fill:#E1C3E6,stroke-width:0px
  style method fill:#ADD8E6,stroke-width:0px
  style output fill:#C5E6A1,stroke-width:0px
  style arg_att1 fill:#DCDCDC,stroke-width:0px
  style arg_att2 fill:#ADD8E6,stroke-width:0px
// ---------------------------------------------------------------------------
//  Convert feature collection into an image. 
//
//  Updated: 10/01/23
// ---------------------------------------------------------------------------

var pond_image ;

print(
  "HELLO POND IMAGE:", 
  pond_image
  )
;

Map.addLayer();

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 4.0 International License.