単純な結合

単純な結合は、フィルタの一致条件に従って、secondary コレクション内の任意の要素と一致する primary コレクションの要素を返します。単純な結合を実行するには、ee.Join.simple() を使用します。これは、異なるコレクションに共通する要素を見つけたり、1 つのコレクションを別のコレクションでフィルタしたりする場合に役立ちます。たとえば、一致する要素が存在する可能性がある 2 つの画像コレクションについて考えてみましょう。ここで、「一致」とは、フィルタで指定された条件によって定義されます。たとえば、一致は画像 ID が等しいことを意味します。両方のコレクション内の一致する画像は同じであるため、単純な結合を使用して、一致する画像のセットを見つけます。

コードエディタ(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 の設定

Python API とインタラクティブな開発で geemap を使用する方法については、 Python 環境のページをご覧ください。

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)

上の例では、結合するコレクションが時間的に約 1 か月重複しています。この結合が適用されると、出力は primary コレクション内の一致する画像のみを含む ImageCollection になります。出力は次のようになります。

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

この出力は、primary コレクションと secondary コレクションの間で、5 月 5 日と 5 月 21 日の 2 つの画像が(フィルタで指定されたように)一致していることを示しています。