Advanced Google Earth Engine API

Geo for Good 2014
October 21, 2014

Tyler Erickson
Senior Developer Advocate, Google Earth Engine

Topics

Geo for Good 2014 - Advanced Earth Engine API

  • Map
  • Reduce
  • Joins
  • Arrays
  • Charting

Map

Map

Geo for Good 2014 - Advanced Earth Engine API

Map

Geo for Good 2014 - Advanced Earth Engine API

Steps:

  • Define a function (javascript or python)
  • Map the function over a collection

Map

Geo for Good 2014 - Advanced Earth Engine API

Steps:

  • Define a function (javascript or python)
  • Map the function over a collection

Under the covers:

    • Run the function once with placeholder variables -> description
    • Server applies description to each element of collection (sort of)
    • Collect the results into a new collection.

Map

Geo for Good 2014 - Advanced Earth Engine API

A Simple Map example

Geo for Good 2014 - Advanced Earth Engine API

Reduce

Reduce in Earth Engine

Geo for Good 2014 - Advanced Earth Engine API

25 reducers

Reducer.allNonZero

Reducer.and

Reducer.anyNonZero

Reducer.count

Reducer.countEvery

Reducer.histogram

Reducer.intervalMean

Reducer.linearFit

Reducer.linearRegression

Reducer.max

Reducer.mean

Reducer.median

Reducer.min

Reducer.minMax

Reducer.mode

Reducer.or

Reducer.percentile

Reducer.product

Reducer.sampleStdDev

Reducer.sampleVariance

Reducer.stdDev

Reducer.sum

Reducer.toCollection

Reducer.toList

Reducer.variance

8 ways to reduce

Image.reduce

Image.reduceNeighborhood

Image.reduceRegion

Image.reduceRegions

Image.reduceToVectors

ImageCollection.reduce

FeatureCollection.reduceColumns

FeatureCollection.reduceToImage

Reduce

Image.reduce (reduce bands of an image)

Geo for Good 2014 - Advanced Earth Engine API

B1

B2

B3

B4

+ B5

103

Example of ee.Image.reduce() - https://ee-api.appspot.com/444eb99a47bb7bdc398fef298a204aac

Reduce

Image.reduceNeighborhood (reduce spatially, per band)

Geo for Good 2014 - Advanced Earth Engine API

B1

B2

B3

B4

B5

Example ee.Image.reduceNeighborhood() - https://ee-api.appspot.com/9d9290736b0448dae68f3100ad0858d7

Reduce

Image.reduceRegion

Geo for Good 2014 - Advanced Earth Engine API

B1

B2

B3

B4

B5

Dictionary

{

B1: 8.3,

B2: 14,

B3: 176,

B4: 1.6,

B5: 7

}

Example of ee.Image.reduceRegion(): https://ee-api.appspot.com/db0fbd9f6a0025e9361cb09328f55851

Reduce

Image.reduceRegions

Geo for Good 2014 - Advanced Earth Engine API

B1

B2

B3

B4

B5

B1

B2

B3

B4

B5

F1

F2

F3

FeatureCollection

F1

F2

F3

Example of ee.Image.reduceRegions() - https://ee-api.appspot.com/35adb7ad23150477697055df9700cd48

Reduce

Image.reduceToVectors

Geo for Good 2014 - Advanced Earth Engine API

labels

B1

B2

B3

B4

B1

B2

B3

B4

F1

F2

F3

F4

F5

...

FeatureCollection

Example of ee.Image.reduceToVectors: https://ee-api.appspot.com/336c4435039a92f643bd94062503f4af

Reduce

ImageCollection.reduce

Geo for Good 2014 - Advanced Earth Engine API

Example ee.ImageCollection.reduce(): https://ee-api.appspot.com/34e9116913044fce4e7cc301f3851564

Reduce

FeatureCollection.reduceToImage

Geo for Good 2014 - Advanced Earth Engine API

Value1

Value2

Value3

Value4

Feature1

Feature2

Feature3

Dictionary

Value1=8.91

Value2=13

Value3=107

Value4=42

Example of FeatureCollection.reduceToImage: https://ee-api.appspot.com/aa41f9d0791257073cc5bdbce9a5fe2e

Reduce

FeatureCollection.reduceColumns

Geo for Good 2014 - Advanced Earth Engine API

B1

B2

B3

B4

F1

F2

F3

F4

F5

...

FeatureCollection

B1

B2

B3

B4

Example ee.FeatureCollection.reduceColumns: https://ee-api.appspot.com/a1d990df0378e216fe9474ecf1218f99

Joins

Joins

Geo for Good 2014 - Advanced Earth Engine API

ee.Join.simple()

ee.Join.inner(primaryKey, secondaryKey, measureKey)

ee.Join.saveAll(matchesKey, ordering, ascending, measureKey)

ee.Join.saveFirst(matchKey, ordering, ascending, measureKey)

ee.Join.saveBest(matchKey, measureKey)

ee.Join.inverted()

C1

C2

F1

F2

+

C3

C4

F1

F2

C1

C2

C3

C4

F1

F2

Joins

Venn diagrams

Geo for Good 2014

ee.Join.simple()

ee.Join.inner()

ee.Join.saveAll()

ee.Join.saveBest()

ee.Join.saveFirst()

ee.Join.inverted()

http://commons.wikimedia.org/wiki/File:Venn0101.svg

Joins

Join.inner (left join, really)

Join.inner

Geo for Good 2014 - Advanced Earth Engine API

C1

C2

F1

F3

+

C3

C4

F1

F2

F3

C1

C2

C3

C4

F1

F3

Joins

Saving joins

Geo for Good 2014 - Advanced Earth Engine API

ee.Join.saveAll(matchesKey, ordering, ascending, measureKey)

join.apply(C1, C2, ee.Filter.withinDistance(5)

Date

X1

Jan 1

X2

Jan 8

X3

Jan 15

X4

Jan 23

X5

Jan 30

Date

Y1

Jan 1

Y2

Jan 3

Y3

Jan 5

Y4

Jan 7

Y5

Jan 9

Date

Matches

X1

Jan 1

[Y1(0), Y2(2), Y3(4)]

X2

Jan 8

[Y3(-3), Y4(-1), Y5(1)]

X3

Jan 15

X4

Jan 23

X5

Jan 30

+

Joins

Simple Example

Geo for Good 2014 - Advanced Earth Engine API

Joins

Simple Example

Geo for Good 2014 - Advanced Earth Engine API

Arrays

Arrays

over 100 array and matrix methods...

Geo for Good 2014 - Advanced Earth Engine API

Arrays

Simple Example (linear regression)

Geo for Good 2014 - Advanced Earth Engine API

Arrays

Simple Example (linear regression - slope of nighttime lights)

Geo for Good 2014 - Advanced Earth Engine API

Questions?