Simple Joins

A simple join returns elements from the primary collection that match any element in the secondary collection according to the match condition in the filter. To perform a simple join, use an ee.Join.simple() . This might be useful for finding the common elements among different collections or filtering one collection by another. For example, consider two image collections which (might) have some matching elements, where “matching” is defined by the condition specified in a filter. For example, let matching mean the image IDs are equal. Since the matching images in both collections are the same, use a simple join to discover this set of matching images:

Code Editor (JavaScript)

 // Load a Landsat 8 image collection at a point of interest. 
 var 
  
 collection 
  
 = 
  
 ee 
 . 
 ImageCollection 
 ( 
 'LANDSAT/LC08/C02/T1_TOA' 
 ) 
  
 . 
 filterBounds 
 ( 
 ee 
 . 
 Geometry 
 . 
 Point 
 ( 
 - 
 122.09 
 , 
  
 37.42 
 )); 
 // Define start and end dates with which to filter the collections. 
 var 
  
 april 
  
 = 
  
 '2014-04-01' 
 ; 
 var 
  
 may 
  
 = 
  
 '2014-05-01' 
 ; 
 var 
  
 june 
  
 = 
  
 '2014-06-01' 
 ; 
 var 
  
 july 
  
 = 
  
 '2014-07-01' 
 ; 
 // The primary collection is Landsat images from April to June. 
 var 
  
 primary 
  
 = 
  
 collection 
 . 
 filterDate 
 ( 
 april 
 , 
  
 june 
 ); 
 // The secondary collection is Landsat images from May to July. 
 var 
  
 secondary 
  
 = 
  
 collection 
 . 
 filterDate 
 ( 
 may 
 , 
  
 july 
 ); 
 // Use an equals filter to define how the collections match. 
 var 
  
 filter 
  
 = 
  
 ee 
 . 
 Filter 
 . 
 equals 
 ({ 
  
 leftField 
 : 
  
 'system:index' 
 , 
  
 rightField 
 : 
  
 'system:index' 
 }); 
 // Create the join. 
 var 
  
 simpleJoin 
  
 = 
  
 ee 
 . 
 Join 
 . 
 simple 
 (); 
 // Apply the join. 
 var 
  
 simpleJoined 
  
 = 
  
 simpleJoin 
 . 
 apply 
 ( 
 primary 
 , 
  
 secondary 
 , 
  
 filter 
 ); 
 // Display the result. 
 print 
 ( 
 'Simple join: ' 
 , 
  
 simpleJoined 
 ); 

Python setup

See the Python Environment page for information on the Python API and using geemap for interactive development.

 import 
  
 ee 
 import 
  
 geemap.core 
  
 as 
  
 geemap 

Colab (Python)

 # Load a Landsat 8 image collection at a point of interest. 
 collection 
 = 
 ee 
 . 
 ImageCollection 
 ( 
 'LANDSAT/LC08/C02/T1_TOA' 
 ) 
 . 
 filterBounds 
 ( 
 ee 
 . 
 Geometry 
 . 
 Point 
 ( 
 - 
 122.09 
 , 
 37.42 
 ) 
 ) 
 # Define start and end dates with which to filter the collections. 
 april 
 = 
 '2014-04-01' 
 may 
 = 
 '2014-05-01' 
 june 
 = 
 '2014-06-01' 
 july 
 = 
 '2014-07-01' 
 # The primary collection is Landsat images from April to June. 
 primary 
 = 
 collection 
 . 
 filterDate 
 ( 
 april 
 , 
 june 
 ) 
 # The secondary collection is Landsat images from May to July. 
 secondary 
 = 
 collection 
 . 
 filterDate 
 ( 
 may 
 , 
 july 
 ) 
 # Use an equals filter to define how the collections match. 
 filter 
 = 
 ee 
 . 
 Filter 
 . 
 equals 
 ( 
 leftField 
 = 
 'system:index' 
 , 
 rightField 
 = 
 'system:index' 
 ) 
 # Create the join. 
 simple_join 
 = 
 ee 
 . 
 Join 
 . 
 simple 
 () 
 # Apply the join. 
 simple_joined 
 = 
 simple_join 
 . 
 apply 
 ( 
 primary 
 , 
 secondary 
 , 
 filter 
 ) 
 # Display the result. 
 display 
 ( 
 'Simple join:' 
 , 
 simple_joined 
 ) 

In the previous example, observe that the collections to join temporally overlap by about a month. Note that when this join is applied, the output will be an ImageCollection with only the matching images in the primary collection. The output should look something like:

Image LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140505 (17 bands)
Image LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140521 (17 bands)

This output shows that two images match (as specified in the filter) between the primary and secondary collections, images at May 5 and May 21.

Create a Mobile Website
View Site in Mobile | Classic
Share by: