Home GIS Applying joins between features in GEE

Applying joins between features in GEE


Joins are used to combine elements from different collections (e.g. Image Collection or Feature Collection) based on a condition specified by a filter in the GEE. The filter is constructed with arguments for the properties in each collection that are related to each other. Specifically, the left Field specifies the property in the primary collection that is related to the right Field in the secondary collection. The type of filter (e.g. equals, greater Than Or Equals, Less Than, etc.) indicates the relationship between the fields. The type of join indicates one-to-many or one-to-one relationships between the elements in the collections and how many matches to retain. The output of a join is produced by join.apply() and will vary according to the type.

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. In my previous post, you can read about computing buffers in GEE. In this article, I focus on outlining the process of applying a simple join between two collections in the Google Earth Engine.

Select an area of interest

In the Google Earth Engine, select the area of interest. It can be a point, line or polygon using the geometry tool.

Configuring geometry Import

Load table for local parks and location

Parks are the primary feature collection and the location of the user is the secondary feature.

var location = ee.FeatureCollection(geometry);
var parks = ee.FeatureCollection('users/mutindarisper/nationalparks');

Create a filter

Apply a filter to pass the left features within a specified distance of the right features. In this case, a distance of 20km is used.

var joinFilter = ee.Filter.withinDistance({
  distance: 20000,
  leftField: 'parks',
  rightField: 'location'

Apply the join

The ‘leftfield’ corresponds to the primary collection and the ‘right Field’ corresponds to the secondary collection.  The matching condition is specified by the filter.

var closeParks = ee.Join.simple().apply({
  primary: parks,
  secondary: location,
  condition: joinFilter
var bufferedLocation = location.map(function(f) { return f.buffer(20000, 100); });

Display final results

Map.setCenter(36.06, -0.29, 13);
Map.addLayer(bufferedLocation, {color: 'b0b0b0'}, 'location');
Map.addLayer(closeParks, {color: '008000'}, 'close parks');
Map.addLayer(table, {color: '007000'}, 'All parks');


Outputs in Google Earth Engine

National Parks


Join Our Mailing List



Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.