Save-All Joins
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
ذخیره اتصالات یکی از راه های نمایش روابط یک به چند در Earth Engine است. برخلاف اتصال داخلی ، یک پیوست ذخیره، مطابق با مجموعه secondary
را به عنوان یک ویژگی نامگذاری شده از ویژگی های مجموعه primary
ذخیره می کند. برای ذخیره همه این موارد، از ee.Join.saveAll()
استفاده کنید. اگر یک رابطه یک به چند وجود داشته باشد، یک saveAll()
join تمام ویژگی های منطبق را به عنوان ee.List
ذخیره می کند. عناصر بیهمتا در مجموعه primary
حذف میشوند. به عنوان مثال، فرض کنید که نیاز به دریافت تمام تصاویر MODIS در طی دو روز از هر تصویر Landsat در یک مجموعه وجود دارد. این مثال از یک join saveAll()
برای این منظور استفاده می کند:
ویرایشگر کد (جاوا اسکریپت)
// 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);
راه اندازی پایتون
برای اطلاعات در مورد API پایتون و استفاده از geemap
برای توسعه تعاملی به صفحه محیط پایتون مراجعه کنید.
import ee
import geemap.core as geemap
کولب (پایتون)
# 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 که محدوده روزانه دارد، فیلتر نقاط پایانی مهرهای زمانی تصویر را مقایسه میکند. Join با نام خاصیت مورد استفاده برای ذخیره لیست منطبقات برای هر تصویر Landsat ( 'terra'
) و پارامتر اختیاری برای مرتب کردن لیست موارد مطابق با ویژگی system:time_start
تعریف می شود.
بررسی نتیجه نشان میدهد که تصاویر درون مجموعه اولیه دارای ویژگی terra
هستند که فهرستی از تصاویر MODIS منطبق را ذخیره میکند.
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-07-25 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-25 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eSaving joins represent one-to-many relationships in Earth Engine by storing matches from a secondary collection as a property in the primary collection.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eee.Join.saveAll()\u003c/code\u003e stores all matching features from the secondary collection as a list in a new property of the primary collection's features, dropping unmatched primary features.\u003c/p\u003e\n"],["\u003cp\u003eThis approach is useful for scenarios like associating all MODIS images within a specific time window to each Landsat image in a collection.\u003c/p\u003e\n"],["\u003cp\u003eThe example code demonstrates filtering and joining Landsat and MODIS collections based on their timestamps, storing the matching MODIS images in a 'terra' property on each Landsat image.\u003c/p\u003e\n"]]],["Saving joins represent one-to-many relationships by storing matches from a secondary collection as a property within the primary collection's features. `ee.Join.saveAll()` stores all matching features as an `ee.List`. The example filters Landsat and MODIS imagery collections, defining a two-day time difference as the matching condition using a time filter. A `saveAll()` join, named `'terra'`, is applied, sorting matches by `system:time_start`. The result has the added property `terra` with a list of matching MODIS images. Unmatched primary collection elements are dropped.\n"],null,["# Save-All Joins\n\nSaving joins are one way of representing one-to-many relationships in Earth Engine.\nUnlike an [inner join](/earth-engine/guides/joins_inner), a saving join stores matches from the\n`secondary` collection as a named property of the features in the\n`primary` collection. To save all such matches, use an\n`ee.Join.saveAll()`. If there is a one-to-many relationship, a\n`saveAll()` join stores all matching features as an\n`ee.List`. Unmatched elements in the `primary` collection are\ndropped. For example, suppose there is a need to get all MODIS imagery acquired\nwithin two days of each Landsat image in a collection. This example uses a\n`saveAll()` join for that purpose:\n\n### Code Editor (JavaScript)\n\n```javascript\n// Load a primary collection: Landsat imagery.\nvar primary = ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA')\n .filterDate('2014-04-01', '2014-06-01')\n .filterBounds(ee.Geometry.Point(-122.092, 37.42));\n\n// Load a secondary collection: MODIS imagery.\nvar modSecondary = ee.ImageCollection('MODIS/006/MOD09GA')\n .filterDate('2014-03-01', '2014-07-01');\n\n// Define an allowable time difference: two days in milliseconds.\nvar twoDaysMillis = 2 * 24 * 60 * 60 * 1000;\n\n// Create a time filter to define a match as overlapping timestamps.\nvar timeFilter = ee.Filter.or(\n ee.Filter.maxDifference({\n difference: twoDaysMillis,\n leftField: 'system:time_start',\n rightField: 'system:time_end'\n }),\n ee.Filter.maxDifference({\n difference: twoDaysMillis,\n leftField: 'system:time_end',\n rightField: 'system:time_start'\n })\n);\n\n// Define the join.\nvar saveAllJoin = ee.Join.saveAll({\n matchesKey: 'terra',\n ordering: 'system:time_start',\n ascending: true\n});\n\n// Apply the join.\nvar landsatModis = saveAllJoin.apply(primary, modSecondary, timeFilter);\n\n// Display the result.\nprint('Join.saveAll:', landsatModis);\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\n# Load a primary collection: Landsat imagery.\nprimary = (\n ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA')\n .filterDate('2014-04-01', '2014-06-01')\n .filterBounds(ee.Geometry.Point(-122.092, 37.42))\n)\n\n# Load a secondary collection: MODIS imagery.\nmod_secondary = ee.ImageCollection('MODIS/006/MOD09GA').filterDate(\n '2014-03-01', '2014-07-01'\n)\n\n# Define an allowable time difference: two days in milliseconds.\ntwo_days_millis = 2 * 24 * 60 * 60 * 1000\n\n# Create a time filter to define a match as overlapping timestamps.\ntime_filter = ee.Filter.Or(\n ee.Filter.maxDifference(\n difference=two_days_millis,\n leftField='system:time_start',\n rightField='system:time_end',\n ),\n ee.Filter.maxDifference(\n difference=two_days_millis,\n leftField='system:time_end',\n rightField='system:time_start',\n ),\n)\n\n# Define the join.\nsave_all_join = ee.Join.saveAll(\n matchesKey='terra', ordering='system:time_start', ascending=True\n)\n\n# Apply the join.\nlandsat_modis = save_all_join.apply(primary, mod_secondary, time_filter)\n\n# Display the result.\ndisplay('Join.saveAll:', landsat_modis)\n```\n\nIn this example, note that the `secondary` MODIS collection is pre-filtered to be\nchronologically similar to the `primary` Landsat collection for efficiency. To\ncompare the Landsat acquisition time to the MODIS composite time, which has a daily range,\nthe filter compares the endpoints of the image timestamps. The join is defined with the\nname of the property used to store the list of matches for each Landsat image\n(`'terra'`) and optional parameter to sort the list of matches by the\n`system:time_start` property\n\nInspection of the result indicates that images within the primary collection have the\nadded `terra` property which stores a list of the matching MODIS images."]]