ee.ImageCollection.sort
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Trie une collection selon la propriété spécifiée.
Renvoie la collection triée.
Utilisation | Renvoie |
---|
ImageCollection.sort(property, ascending) | Collection |
Argument | Type | Détails |
---|
ceci : collection | Collection | Instance de la collection. |
property | Chaîne | Propriété à utiliser pour le tri. |
ascending | Booléen, facultatif | Indique si le tri doit être effectué par ordre croissant ou décroissant. La valeur par défaut est "true" (croissant). |
Exemples
Éditeur de code (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');
Configuration de Python
Consultez la page
Environnement Python pour en savoir plus sur l'API Python et sur l'utilisation de geemap
pour le développement interactif.
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
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/07/29 (UTC).
[null,null,["Dernière mise à jour le 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```"]]