简单联接会根据过滤条件中的匹配条件,返回 primary
集合中与 secondary
集合中的任何元素匹配的元素。如需执行简单联接,请使用 ee.Join.simple()
。这对于查找不同集合中的共同元素或按另一个集合过滤一个集合可能很有用。例如,假设有两个图片集合(可能)包含一些匹配的元素,其中“匹配”是指过滤条件中指定的条件。例如,假设匹配是指图片 ID 相等。由于这两个集合中的匹配图片相同,因此只需使用简单的联接即可发现这组匹配图片:
// 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);
import ee import geemap.core as geemap
# 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)
此输出显示 primary
和 secondary
集合中有两个图片匹配(如过滤条件中所指定),分别是 5 月 5 日和 5 月 21 日的图片。