0

I am pretty new on GEE and idk how easy is this task. I want to find daily precipitation for all Brazilian municipalities in 2006. I applied a map function with reduce regions and end up with a feature collection of municipalities. But I really need the date of reference for each element (day and month). I tried to use set function but idk how to guarantee each information would have the correct date from the image that was calculated. My ending goal is a table to export to google drive.

Here's my code:

var mun = ee.FeatureCollection("users/rodrigoccuri/BRMUE250GC_SIR");

// Importing Chirps dataset:
var chirps = ee.ImageCollection('UCSB-CHG/CHIRPS/DAILY');

// Filtering year 2006:
var chirps06 = chirps.filterDate('2006-01-01', '2006-12-31');

// Creating a function to reduce regions for each image by pixel mean for mun:
var reduce = function(image) {
  return image.reduceRegions(mun, ee.Reducer.mean(), 1000)
}

// Appling reducer for each image in the collection:
var precmun06 = chirps06.map(reduce).flatten();

print(precmun06.first());
0

While mapping over your chirps data, you need to set the date on each municipality:

var reduce = function(image) {
  return image.reduceRegions(mun, ee.Reducer.mean(), 1000) A FeatureCollection of municipalities
    .map(function (feature) { // You want assign the date to each of these
      return feature // You needed month and day separately?
        .set('month', image.date().get('month'))
        .set('day', image.date().get('day'))
    })
}

https://code.earthengine.google.com/18029656e797fd35d9c0a1f37e3c0d62

1
  • Thanks so much and sorry for the late response. I've been trying to run it now and have founded some error message to export (Error: Execution failed (internal error)). I run it before and really don't know now what is happenning. Any clue? Thanks! Apr 16 '20 at 21:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.