การรวมแบบง่าย

การรวมแบบง่ายจะแสดงผลองค์ประกอบจากคอลเล็กชัน primary ที่ตรงกับองค์ประกอบใดก็ได้ในคอลเล็กชัน secondary ตามเงื่อนไขการจับคู่ในตัวกรอง หากต้องการเข้าร่วมแบบง่าย ให้ใช้ ee.Join.simple() ซึ่งอาจมีประโยชน์ในการค้นหาองค์ประกอบที่เหมือนกันในคอลเล็กชันต่างๆ หรือกรองคอลเล็กชันหนึ่งตามอีกคอลเล็กชันหนึ่ง ตัวอย่างเช่น พิจารณาคอลเล็กชันรูปภาพ 2 รายการที่ (อาจ) มีองค์ประกอบที่ตรงกันบางส่วน โดยที่ "การจับคู่" นั้นกำหนดโดยเงื่อนไขที่ระบุไว้ในตัวกรอง ตัวอย่างเช่น สมมติว่า "การจับคู่" หมายถึงรหัสรูปภาพเท่ากัน เนื่องจากรูปภาพที่ตรงกันในคอลเล็กชันทั้ง 2 ชุดเหมือนกัน ให้ใช้การรวมแบบง่ายเพื่อค้นหาชุดรูปภาพที่ตรงกันนี้

เครื่องมือแก้ไขโค้ด (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 เดือน โปรดทราบว่าเมื่อใช้การเข้าร่วมนี้ เอาต์พุตจะเป็นImageCollectionที่มีเฉพาะรูปภาพที่ตรงกันในคอลเล็กชัน primary เอาต์พุตควรมีลักษณะดังนี้

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

เอาต์พุตนี้แสดงว่ารูปภาพ 2 รูปตรงกัน (ตามที่ระบุไว้ในตัวกรอง) ระหว่างคอลเล็กชัน primary กับ secondary ซึ่งเป็นรูปภาพในวันที่ 5 พฤษภาคมและ 21 พฤษภาคม