Google Earth Engine (GEE) -- a case study of Join connection

Posted by Angus on Tue, 21 Dec 2021 01:50:41 +0100

Join is used to combine elements from different collections (such as ImageCollection or FeatureCollection) according to specified conditions. The filter is constructed with parameters of attributes related to each other in each collection. Specifically, leftField specifies the attribute rightField in the primary collection related to the secondary collection. The type of filter (e.g., equals, greaterThanOrEquals, lessThan, etc.) indicates the relationship between fields. The type of connection indicates the one-to-many or one-to-one relationship between elements in the collection and the number of matches to keep. The output of the connection is generated by the type of join.apply() connection and will vary according to the type of connection.

Simple join returns the elements that match any element in the collection from the primary collection according to the matching criteria in the filter. To perform a simple connection, use EE Join. simple(). This can be useful for finding common elements between different collections or filtering a collection through another collection. For example, consider two (possibly) sets of images with some matching elements, where "matching" is defined by the criteria specified in the filter. For example, making matching means equal image ID s. Since the matching images in the two sets are the same, use a simple connection to discover this set of matching images:

Function:

ee.Filter.equals(leftField, rightValue, rightField, leftValue)

Creates a unary or binary filter that passes if the two operands are equal.

Creates a unary or binary filter that passes if the two operands are equals.

Arguments:

leftField(String, default: null): 
Left operand selector. If specified leftValue,Should not be specified.

rightValue(Object, default: null): 
The value of the right operand. If specified rightField,Should not be specified.

rightField(String, default: null): 
The selector for the right operand. If specified rightValue,Should not be specified.

leftValue(Object, default: null): 
The value of the left operand. If specified leftField,Should not be specified.

leftField (String, default: null):

A selector for the left operand. Should not be specified if leftValue is specified.

rightValue (Object, default: null):

The value of the right operand. Should not be specified if rightField is specified.

rightField (String, default: null):

A selector for the right operand. Should not be specified if rightValue is specified.

leftValue (Object, default: null):

The value of the left operand. Should not be specified if leftField is specified.

Returns: Filter

ee.Join.simple()

Returns a connection that generates elements of the primary collection that match any elements of the secondary collection. No attributes were added to the results.

Returns a join that produces the elements of the primary collection that match any element of the secondary collection. No properties are added to the results.

No arguments.

Returns: Join

code:

// Load the Landsat 8 image collection at the point of interest.
var collection = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA')
    .filterBounds(ee.Geometry.Point(-122.09, 37.42));

// Define the start and end dates of the filter set.
var april = '2014-04-01';
var may = '2014-05-01';
var june = '2014-06-01';
var july = '2014-07-01';

//The first part is a collection of Landsat images from April to June.
var primary = collection.filterDate(april, june);

// The second part of the image set is Landsat images from May to July.
var secondary = collection.filterDate(may, july);

// Use the equals filter to define how the collection matches. Here is the system pointer
var filter = ee.Filter.equals({
  leftField: 'system:index',
  rightField: 'system:index'
});

// Create connection
var simpleJoin = ee.Join.simple();

// Application connection
var simpleJoined = simpleJoin.apply(primary, secondary, filter);

// Show results
print('Simple join: ', simpleJoined);

result:

In the previous example, observe that the set to be added overlaps in time for about a month. Note that when this connection is applied, the output will be the image collection containing only the matching images in the primary collection. The output should look like:

This output shows two images matching between the primary and secondary sets (as specified in the filter), that is, the images on days 125 and 141 of the year or on May 5 and May 21.

Topics: GEE