sortMany#
- geetools.ee_image_collection.ImageCollectionAccessor.sortMany(properties, ascending=None)#
Sort an ImageCollection using more than 1 property.
The properties are set in the order of priority. The first property is the most important one, in case of a tie, the second property is used to break the tie, and so on.
Warning
This method will raise an error if the 2 parameter are not the same size.
- Parameters:
- Return type:
Examples
import ee, geetools from geetools.utils import initialize_documentation initialize_documentation() # order the 500 first images of the NOAA forecast by forecasted date. in case of tie, # order by creation date. We limit to 500 to not exceed GEE computation limits² ic = ee.ImageCollection("NOAA/GFS0P25").limit(500) icSorted = ic.geetools.sortMany(["forecast_time", "creation_time"]) # print the sorted list of images with forecast and creation time properties for the 10 first icSorted = icSorted.limit(10) info = icSorted.toList(icSorted.size()).map(lambda x: ee.Dictionary({ "forecast_time": ee.Date(ee.Image(x).get("forecast_time")).format(), "creation_time": ee.Date(ee.Image(x).get("creation_time")).format() })) for item in info.getInfo(): print(f"Forecast Time: {item['forecast_time']}, Creation Time: {item['creation_time']}")
Forecast Time: 2015-04-01T03:00:00, Creation Time: 2015-04-01T00:00:00 Forecast Time: 2015-04-01T06:00:00, Creation Time: 2015-04-01T00:00:00 Forecast Time: 2015-04-01T09:00:00, Creation Time: 2015-04-01T00:00:00 Forecast Time: 2015-04-01T09:00:00, Creation Time: 2015-04-01T06:00:00 Forecast Time: 2015-04-01T12:00:00, Creation Time: 2015-04-01T00:00:00 Forecast Time: 2015-04-01T12:00:00, Creation Time: 2015-04-01T06:00:00 Forecast Time: 2015-04-01T15:00:00, Creation Time: 2015-04-01T00:00:00 Forecast Time: 2015-04-01T15:00:00, Creation Time: 2015-04-01T06:00:00 Forecast Time: 2015-04-01T15:00:00, Creation Time: 2015-04-01T12:00:00 Forecast Time: 2015-04-01T18:00:00, Creation Time: 2015-04-01T00:00:00