doyByYears#
- geetools.ee_image_collection.ImageCollectionAccessor.doyByYears(band, region, reducer='mean', dateProperty='system:time_start', scale=10000, crs=None, crsTransform=None, bestEffort=False, maxPixels=10**7, tileScale=1)#
Aggregate for each year on a single region a single band.
This method is returning a dictionary with all the years as keys and their reduced value for each day over the specified region for a specific band as value.
{ "year1": {"doy1": value1, "doy2": value2, ...}, "year2": {"doy1": value1, "doy2": value2, ...}, ... }
- Parameters:
band (str) – The band to reduce.
region (ee.Geometry) – The region to reduce the data on.
reducer (str | ee.Reducer) – The name of the reducer or a reducer object to use. Default is
"mean".dateProperty (str) – The property to use as date for each image. Default is
"system:time_start".scale (int) – The scale in meters to use for the reduction. default is 10000m
crs (str | None) – The projection to work in. If unspecified, the projection of the image’s first band is used. If specified in addition to scale, rescaled to the specified scale.
crsTransform (list | None) – The list of CRS transform values. This is a row-major ordering of the 3x2 transform matrix. This option is mutually exclusive with ‘scale’, and replaces any transform already set on the projection.
bestEffort (bool) – If the polygon would contain too many pixels at the given scale, compute and use a larger scale which would allow the operation to succeed.
maxPixels (int | None) – The maximum number of pixels to reduce. Defaults to 1e7.
tileScale (float) – A scaling factor between 0.1 and 16 used to adjust aggregation tile size; setting a larger tileScale (e.g., 2 or 4) uses smaller tiles and may enable computations that run out of memory with the default.
- Returns:
A dictionary with the reduced values for each year and each day.
- Return type:
See also
doyByBands: Aggregate the images that occurs on the same day and then reduce each band on a single region.doyByRegions: Aggregate the images that occurs on the same day and then reduce a single band on multiple regions.doyBySeasons: Aggregate for each year on a single region a single band.plot_doy_by_bands: Plot the reduced data for each image in the collection by bands on a specific region.plot_doy_by_regions: Plot the reduced data for each image in the collection by regions for a single band.plot_doy_by_seasons: Plot the reduced data for each image in the collection by years for a single band.plot_doy_by_years: Plot the reduced data for each image in the collection by years for a single band.
Examples
import ee, geetools from geetools.utils import initialize_documentation initialize_documentation() collection = ( ee.ImageCollection("LANDSAT/LC08/C02/T1_TOA") .filterBounds(ee.Geometry.Point(-122.262, 37.8719)) .filter(ee.Filter.Or( ee.Filter.date("2022-01-01", "2022-12-31"), ee.Filter.date("2016-01-01", "2016-12-31"), )) .map(lambda i: ee.Image(i).addBands( ee.Image(i) .normalizedDifference(["B5", "B4"]) .rename("NDVI") )) ) reduced = collection.geetools.doyByYears( band = "NDVI", region = ee.Geometry.Point(-122.262, 37.8719).buffer(1000), reducer = "mean", dateProperty = "system:time_start", scale = 10000 ) reduced.getInfo()
{'2016': {'114': 0.5602087093993884, '130': 0.5567390104809519, '146': 0.5320520800514571, '162': 0.38296301942341515, '178': 0.48876907548560816, '194': 0.4277642839266327, '2': 0.18039120971768205, '210': 0.4695113426976842, '226': 0.44273214236227504, '242': 0.40626011961747965, '258': 0.3850503530508611, '274': 0.44472521772378426, '290': 0.4008216852872101, '306': 0.51172048910413, '322': 0.47783248176314247, '338': 0.39035549793548036, '34': 0.5018829275313158, '354': 0.39082736909849486, '50': 0.4672897301155814, '66': 0.039181623854979704, '82': 0.5216778326026866, '98': 0.04983350141352292}, '2022': {'114': 0.5307749085358947, '130': 0.4956961333546755, '146': 0.08797856743167884, '162': 0.05910096371491292, '178': 0.49401842744569574, '18': 0.42744229250463855, '194': 0.45398605392772073, '2': 0.06448681769379908, '210': 0.1768454152745308, '226': 0.49199842015256107, '242': 0.41926775357483387, '258': 0.4534184981687464, '274': 0.42303466742879897, '290': 0.492751970875086, '306': 0.4884940267108327, '322': 0.5190275017036148, '338': 0.019854696159657285, '34': 0.506291016501142, '354': 0.35483874214776234, '50': 0.13262948040207623, '66': 0.49592781396354657, '82': 0.584249248089327, '98': 0.5946662139123087}}