किसी कलेक्शन में हर एलिमेंट के लिए सिर्फ़ सबसे अच्छा मैच सेव करने के लिए, ee.Join.saveBest()
का इस्तेमाल करें. saveBest()
जॉइन फ़ंक्शन, saveAll()
जॉइन फ़ंक्शन की तरह ही काम करता है. हालांकि, primary
कलेक्शन के हर एलिमेंट के लिए, यह secondary
कलेक्शन से सबसे अच्छे मैच वाले एलिमेंट को सेव करता है. प्राइमरी कलेक्शन में मौजूद मैच न करने वाले एलिमेंट को हटा दिया जाता है. मान लें कि आपको primary
कलेक्शन में मौजूद हर Landsat इमेज के आस-पास की मौसम की जानकारी वाली इमेज ढूंढनी है. यह जॉइन करने के लिए, एक ही जॉइन कंडीशन के लिए ee.Filter
को फिर से तय करना होगा. saveBest()
के साथ, कई सब-फ़िल्टर से रैंक को जोड़ने का तरीका साफ़ तौर पर नहीं बताया गया है, इसलिए कई फ़िल्टर को जोड़ने वाले फ़िल्टर काम नहीं करेंगे:
कोड एडिटर (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: GRIDMET meteorological data var gridmet = ee.ImageCollection('IDAHO_EPSCOR/GRIDMET'); // Define a max difference filter to compare timestamps. var maxDiffFilter = ee.Filter.maxDifference({ difference: 2 * 24 * 60 * 60 * 1000, leftField: 'system:time_start', rightField: 'system:time_start' }); // Define the join. var saveBestJoin = ee.Join.saveBest({ matchKey: 'bestImage', measureKey: 'timeDiff' }); // Apply the join. var landsatMet = saveBestJoin.apply(primary, gridmet, maxDiffFilter); // Print the result. print(landsatMet);
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: GRIDMET meteorological data gridmet = ee.ImageCollection('IDAHO_EPSCOR/GRIDMET') # Define a max difference filter to compare timestamps. max_diff_filter = ee.Filter.maxDifference( difference=2 * 24 * 60 * 60 * 1000, leftField='system:time_start', rightField='system:time_start', ) # Define the join. save_best_join = ee.Join.saveBest(matchKey='bestImage', measureKey='timeDiff') # Apply the join. landsat_met = save_best_join.apply(primary, gridmet, max_diff_filter) # Print the result. display(landsat_met)
ध्यान दें कि saveBest()
जॉइन, उस प्रॉपर्टी का नाम तय करता है जिसमें सबसे अच्छा मैच (‘bestImage’
) सेव किया जाना है. साथ ही, उस प्रॉपर्टी का नाम भी तय करता है जिसमें मैच मेट्रिक की परफ़ॉर्मेंस (‘timeDiff’
) सेव की जानी है. नतीजों की जांच करने से पता चलता है कि primary
कलेक्शन में मौजूद हर Landsat सीन के लिए, प्रॉपर्टी bestImage
में मैच करने वाली DAYMET इमेज जोड़ी गई है. इनमें से हर DAYMET इमेज में timeDiff
प्रॉपर्टी होती है, जो DAYMET इमेज और Landsat इमेज के बीच के समय के अंतर को मिलीसेकंड में दिखाती है. यह फ़िल्टर की शर्त को पूरा करने वाली DAYMET इमेज में सबसे कम होगा.