ee.ImageCollection.sort
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
מיון אוסף לפי הנכס שצוין.
הפונקציה מחזירה את האוסף הממוין.
שימוש | החזרות |
---|
ImageCollection.sort(property, ascending) | אוסף |
ארגומנט | סוג | פרטים |
---|
זה: collection | אוסף | מופע האוסף. |
property | מחרוזת | המאפיין שלפיו יתבצע המיון. |
ascending | בוליאני, אופציונלי | האם למיין בסדר עולה או יורד. ברירת המחדל היא true (סדר עולה). |
דוגמאות
עורך הקוד (JavaScript)
// A Landsat 8 TOA image collection (2 months of images at a specific point).
var col = ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA')
.filterBounds(ee.Geometry.Point(-90.70, 34.71))
.filterDate('2020-07-01', '2020-09-01');
print('Collection', col);
// Sort the collection in ASCENDING order of image cloud cover.
var colCldSortAsc = col.sort('CLOUD_COVER');
print('Cloud cover ascending', colCldSortAsc);
// Display the image with the least cloud cover.
var visParams = {
bands: ['B4', 'B3', 'B2'],
min: 0.01,
max: 0.25
};
Map.setCenter(-90.70, 34.71, 9);
Map.addLayer(colCldSortAsc.first(), visParams, 'Least cloudy');
// Sort the collection in DESCENDING order of image cloud cover.
var colCldSortDesc = col.sort('CLOUD_COVER', false);
print('Cloud cover descending', colCldSortDesc);
// Display the image with the most cloud cover.
Map.addLayer(colCldSortDesc.first(), visParams, 'Most cloudy');
הגדרת Python
מידע על Python API ועל שימוש ב-geemap
לפיתוח אינטראקטיבי מופיע בדף
Python Environment.
import ee
import geemap.core as geemap
Colab (Python)
# A Landsat 8 TOA image collection (2 months of images at a specific point).
col = (
ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA')
.filterBounds(ee.Geometry.Point(-90.70, 34.71))
.filterDate('2020-07-01', '2020-09-01')
)
display('Collection', col)
# Sort the collection in ASCENDING order of image cloud cover.
col_cld_sort_asc = col.sort('CLOUD_COVER')
display('Cloud cover ascending', col_cld_sort_asc)
# Display the image with the least cloud cover.
vis_params = {'bands': ['B4', 'B3', 'B2'], 'min': 0.01, 'max': 0.25}
m = geemap.Map()
m.set_center(-90.70, 34.71, 9)
m.add_layer(col_cld_sort_asc.first(), vis_params, 'Least cloudy')
# Sort the collection in DESCENDING order of image cloud cover.
col_cld_sort_desc = col.sort('CLOUD_COVER', False)
display('Cloud cover descending', col_cld_sort_desc)
# Display the image with the most cloud cover.
m.add_layer(col_cld_sort_desc.first(), vis_params, 'Most cloudy')
m
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-29 (שעון UTC).
[null,null,["עדכון אחרון: 2025-07-29 (שעון UTC)."],[[["\u003cp\u003eThe \u003ccode\u003esort()\u003c/code\u003e method allows you to order an ImageCollection based on a specified property, such as cloud cover.\u003c/p\u003e\n"],["\u003cp\u003eBy default, \u003ccode\u003esort()\u003c/code\u003e arranges the collection in ascending order; to sort in descending order, set the \u003ccode\u003eascending\u003c/code\u003e parameter to \u003ccode\u003efalse\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThis method is useful for tasks like identifying images with the least or most cloud cover within a collection.\u003c/p\u003e\n"],["\u003cp\u003eThe sorted collection is returned, enabling further processing or analysis.\u003c/p\u003e\n"]]],[],null,["# ee.ImageCollection.sort\n\n\u003cbr /\u003e\n\nSort a collection by the specified property.\n\n\u003cbr /\u003e\n\nReturns the sorted collection.\n\n| Usage | Returns |\n|-------------------------------------------------|------------|\n| ImageCollection.sort`(property, `*ascending*`)` | Collection |\n\n| Argument | Type | Details |\n|--------------------|-------------------|------------------------------------------------------------------------------------|\n| this: `collection` | Collection | The Collection instance. |\n| `property` | String | The property to sort by. |\n| `ascending` | Boolean, optional | Whether to sort in ascending or descending order. The default is true (ascending). |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// A Landsat 8 TOA image collection (2 months of images at a specific point).\nvar col = ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA')\n .filterBounds(ee.Geometry.Point(-90.70, 34.71))\n .filterDate('2020-07-01', '2020-09-01');\nprint('Collection', col);\n\n// Sort the collection in ASCENDING order of image cloud cover.\nvar colCldSortAsc = col.sort('CLOUD_COVER');\nprint('Cloud cover ascending', colCldSortAsc);\n\n// Display the image with the least cloud cover.\nvar visParams = {\n bands: ['B4', 'B3', 'B2'],\n min: 0.01,\n max: 0.25\n};\nMap.setCenter(-90.70, 34.71, 9);\nMap.addLayer(colCldSortAsc.first(), visParams, 'Least cloudy');\n\n// Sort the collection in DESCENDING order of image cloud cover.\nvar colCldSortDesc = col.sort('CLOUD_COVER', false);\nprint('Cloud cover descending', colCldSortDesc);\n\n// Display the image with the most cloud cover.\nMap.addLayer(colCldSortDesc.first(), visParams, 'Most cloudy');\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# A Landsat 8 TOA image collection (2 months of images at a specific point).\ncol = (\n ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA')\n .filterBounds(ee.Geometry.Point(-90.70, 34.71))\n .filterDate('2020-07-01', '2020-09-01')\n)\ndisplay('Collection', col)\n\n# Sort the collection in ASCENDING order of image cloud cover.\ncol_cld_sort_asc = col.sort('CLOUD_COVER')\ndisplay('Cloud cover ascending', col_cld_sort_asc)\n\n# Display the image with the least cloud cover.\nvis_params = {'bands': ['B4', 'B3', 'B2'], 'min': 0.01, 'max': 0.25}\nm = geemap.Map()\nm.set_center(-90.70, 34.71, 9)\nm.add_layer(col_cld_sort_asc.first(), vis_params, 'Least cloudy')\n\n# Sort the collection in DESCENDING order of image cloud cover.\ncol_cld_sort_desc = col.sort('CLOUD_COVER', False)\ndisplay('Cloud cover descending', col_cld_sort_desc)\n\n# Display the image with the most cloud cover.\nm.add_layer(col_cld_sort_desc.first(), vis_params, 'Most cloudy')\nm\n```"]]