Announcement: All noncommercial projects registered to use Earth Engine before
April 15, 2025 must
verify noncommercial eligibility to maintain Earth Engine access.
Inverted Joins
Stay organized with collections
Save and categorize content based on your preferences.
Suppose that the purpose of the join is to retain all images in the primary
collection that are not in the secondary
collection. You can perform this
type of inverted join using ee.Join.inverted()
.
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'
});
// Define the join.
var invertedJoin = ee.Join.inverted();
// Apply the join.
var invertedJoined = invertedJoin.apply(primary, secondary, filter);
// Print the result.
print('Inverted join:', invertedJoined);
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')
# Define the join.
inverted_join = ee.Join.inverted()
# Apply the join.
inverted_joined = inverted_join.apply(primary, secondary, filter)
# Print the result.
display('Inverted join:', inverted_joined)
The output should look something like:
Image LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140403 (17 bands)
Image LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140419 (17 bands)
The inverted join contains the images from April 3 and April 19, indicating the images
that are present in the primary
collection but not in the
secondary
collection.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-12-27 UTC.
[null,null,["Last updated 2024-12-27 UTC."],[[["\u003cp\u003e\u003ccode\u003eee.Join.inverted()\u003c/code\u003e allows you to keep images from a primary collection that do not have matching images in a secondary collection based on a specified filter.\u003c/p\u003e\n"],["\u003cp\u003eThis example demonstrates how to use \u003ccode\u003eee.Join.inverted()\u003c/code\u003e to identify Landsat 8 images from April that are not present in the May to July timeframe.\u003c/p\u003e\n"],["\u003cp\u003eAn \u003ccode\u003eee.Filter.equals()\u003c/code\u003e is employed to define matching criteria between the collections, typically using a common property like 'system:index'.\u003c/p\u003e\n"],["\u003cp\u003eThe resulting collection contains only images unique to the primary collection, effectively isolating images not found in the secondary collection.\u003c/p\u003e\n"]]],["The content demonstrates how to use `ee.Join.inverted()` to retain images from a `primary` collection that are absent in a `secondary` collection. It involves loading a Landsat 8 image collection and defining `primary` (April-June) and `secondary` (May-July) collections. An equals filter is used to match images by their system index. The `invertedJoin` is defined and applied, resulting in images present in the `primary` but not in the `secondary` collection, exemplified by images from April 3rd and 19th.\n"],null,["# Inverted Joins\n\nSuppose that the purpose of the join is to retain all images in the `primary`\ncollection that are not in the `secondary` collection. You can perform this\ntype of inverted join using `ee.Join.inverted()`.\n\n### Code Editor (JavaScript)\n\n```javascript\n// Load a Landsat 8 image collection at a point of interest.\nvar collection = ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA')\n .filterBounds(ee.Geometry.Point(-122.09, 37.42));\n\n// Define start and end dates with which to filter the collections.\nvar april = '2014-04-01';\nvar may = '2014-05-01';\nvar june = '2014-06-01';\nvar july = '2014-07-01';\n\n// The primary collection is Landsat images from April to June.\nvar primary = collection.filterDate(april, june);\n\n// The secondary collection is Landsat images from May to July.\nvar secondary = collection.filterDate(may, july);\n\n// Use an equals filter to define how the collections match.\nvar filter = ee.Filter.equals({\n leftField: 'system:index',\n rightField: 'system:index'\n});\n\n// Define the join.\nvar invertedJoin = ee.Join.inverted();\n\n// Apply the join.\nvar invertedJoined = invertedJoin.apply(primary, secondary, filter);\n\n// Print the result.\nprint('Inverted join:', invertedJoined);\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\n# Load a Landsat 8 image collection at a point of interest.\ncollection = ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA').filterBounds(\n ee.Geometry.Point(-122.09, 37.42)\n)\n\n# Define start and end dates with which to filter the collections.\napril = '2014-04-01'\nmay = '2014-05-01'\njune = '2014-06-01'\njuly = '2014-07-01'\n\n# The primary collection is Landsat images from April to June.\nprimary = collection.filterDate(april, june)\n\n# The secondary collection is Landsat images from May to July.\nsecondary = collection.filterDate(may, july)\n\n# Use an equals filter to define how the collections match.\nfilter = ee.Filter.equals(leftField='system:index', rightField='system:index')\n\n# Define the join.\ninverted_join = ee.Join.inverted()\n\n# Apply the join.\ninverted_joined = inverted_join.apply(primary, secondary, filter)\n\n# Print the result.\ndisplay('Inverted join:', inverted_joined)\n```\n\nThe output should look something like: \n\n```\nImage LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140403 (17 bands)\nImage LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140419 (17 bands)\n```\n\nThe inverted join contains the images from April 3 and April 19, indicating the images\nthat are present in the `primary` collection but not in the\n`secondary` collection."]]