सभी जॉइन सेव करना

जॉइन सेव करना, Earth Engine में एक-से-कई रिलेशनशिप दिखाने का एक तरीका है. इनर जॉइन के उलट, सेविंग जॉइन, secondary कलेक्शन से मैच करने वाले डेटा को primary कलेक्शन में मौजूद सुविधाओं की नाम वाली प्रॉपर्टी के तौर पर सेव करता है. ऐसे सभी मैच सेव करने के लिए, ee.Join.saveAll() का इस्तेमाल करें. अगर एक-से-कई संबंध है, तो एक saveAll() जॉइन, मैच होने वाली सभी सुविधाओं को एक ee.List के तौर पर सेव करता है. primary कलेक्शन में मौजूद मैच न करने वाले एलिमेंट को हटा दिया जाता है. उदाहरण के लिए, मान लें कि आपको किसी कलेक्शन में मौजूद हर Landsat इमेज के दो दिन के अंदर, MODIS की सभी इमेज चाहिए. इस उदाहरण में, इस काम के लिए saveAll() जॉइन का इस्तेमाल किया गया है:

कोड एडिटर (JavaScript)

// Load a primary collection: Landsat imagery.
var primary = ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA')
    .filterDate('2014-04-01', '2014-06-01')
    .filterBounds(ee.Geometry.Point(-122.092, 37.42));

// Load a secondary collection: MODIS imagery.
var modSecondary = ee.ImageCollection('MODIS/006/MOD09GA')
    .filterDate('2014-03-01', '2014-07-01');

// Define an allowable time difference: two days in milliseconds.
var twoDaysMillis = 2 * 24 * 60 * 60 * 1000;

// Create a time filter to define a match as overlapping timestamps.
var timeFilter = ee.Filter.or(
  ee.Filter.maxDifference({
    difference: twoDaysMillis,
    leftField: 'system:time_start',
    rightField: 'system:time_end'
  }),
  ee.Filter.maxDifference({
    difference: twoDaysMillis,
    leftField: 'system:time_end',
    rightField: 'system:time_start'
  })
);

// Define the join.
var saveAllJoin = ee.Join.saveAll({
  matchesKey: 'terra',
  ordering: 'system:time_start',
  ascending: true
});

// Apply the join.
var landsatModis = saveAllJoin.apply(primary, modSecondary, timeFilter);

// Display the result.
print('Join.saveAll:', landsatModis);

Python सेटअप

Python API के बारे में जानकारी पाने और इंटरैक्टिव डेवलपमेंट के लिए geemap का इस्तेमाल करने के लिए, Python एनवायरमेंट पेज देखें.

import ee
import geemap.core as geemap

Colab (Python)

# Load a primary collection: Landsat imagery.
primary = (
    ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA')
    .filterDate('2014-04-01', '2014-06-01')
    .filterBounds(ee.Geometry.Point(-122.092, 37.42))
)

# Load a secondary collection: MODIS imagery.
mod_secondary = ee.ImageCollection('MODIS/006/MOD09GA').filterDate(
    '2014-03-01', '2014-07-01'
)

# Define an allowable time difference: two days in milliseconds.
two_days_millis = 2 * 24 * 60 * 60 * 1000

# Create a time filter to define a match as overlapping timestamps.
time_filter = ee.Filter.Or(
    ee.Filter.maxDifference(
        difference=two_days_millis,
        leftField='system:time_start',
        rightField='system:time_end',
    ),
    ee.Filter.maxDifference(
        difference=two_days_millis,
        leftField='system:time_end',
        rightField='system:time_start',
    ),
)

# Define the join.
save_all_join = ee.Join.saveAll(
    matchesKey='terra', ordering='system:time_start', ascending=True
)

# Apply the join.
landsat_modis = save_all_join.apply(primary, mod_secondary, time_filter)

# Display the result.
display('Join.saveAll:', landsat_modis)

इस उदाहरण में, ध्यान दें कि secondary MODIS कलेक्शन को पहले से फ़िल्टर किया गया है, ताकि समय के हिसाब से यह primary लैंडसेट कलेक्शन से मिलता-जुलता हो. इससे, बेहतर परफ़ॉर्मेंस मिलती है. Landsat के डेटा इकट्ठा करने के समय की तुलना, MODIS के कंपोजिट समय से करने के लिए, फ़िल्टर, इमेज के टाइमस्टैंप के एंडपॉइंट की तुलना करता है. MODIS के कंपोजिट समय की सीमा, हर दिन की होती है. जॉइन को प्रॉपर्टी के नाम के साथ परिभाषित किया जाता है, जिसका इस्तेमाल हर Landsat इमेज (‘terra’) के लिए मैच की सूची को सेव करने के लिए किया जाता है. साथ ही, system:time_start प्रॉपर्टी के हिसाब से मैच की सूची को क्रम से लगाने के लिए, वैकल्पिक पैरामीटर का इस्तेमाल किया जाता है

नतीजे की जांच से पता चलता है कि प्राइमरी कलेक्शन में मौजूद इमेज में, जोड़ी गई terra प्रॉपर्टी है. यह प्रॉपर्टी, मैच होने वाली MODIS इमेज की सूची सेव करती है.