0

I have an asset of 25k geometries. I also have a function that maps over a list of years to find mean rainfall for a region. I was able to do this using a for loop when I had fewer regions:

def yearlyRainfall(year):
    startDate = ee.Date.fromYMD(year, 1, 1)
    endDate = startDate.advance(1, 'year')
    filtered = chirps.filter(ee.Filter.date(startDate, endDate))
    total = filtered.reduce(ee.Reducer.sum())
    stats = total.reduceRegion(
      reducer = ee.Reducer.mean(),
      geometry = transect_region,
      scale = 5566,
    )
    f = ee.Feature(None,{
      'year': year,
      'precipitation': stats.get('precipitation_sum')
    })
    return f
years = ee.List.sequence(1981, 2019)
for area in range(len(transect_areas)):
  transect_region = transect_areas[area].geometry()
  rainfallYears = ee.FeatureCollection(years.map(yearlyRainfall))
  rainfalldf = geemap.ee_to_pandas(rainfallYears)
  print(rainfalldf)
  print(rainfalldf["precipitation"].mean())

Where transect_areas is a dictionary of regions. However, I now have to do this over 25k geometries held in a csv asset, and cannot achieve this through a for loop. I know I have to map it somehow, but I can't figure out a workaround. Any tips would be appreciated.

Tried: looping over dictionary of regions, but computation does not complete

rg64
  • 1

0 Answers0