Wednesday, 8 April 2015

Retrieving monthly rainfall averages for Feature Collection in Google Earth Engine?


I am trying to retrieve monthly rainfall averages for points stored in a feature collection. I have checked other posts with similar questions but I cannot seem to figure out how to adapt their solutions to my case. This is my code for the daily precipitation values.


How would I have to modify it to get monthly values?


var fg_points = 
ee.FeatureCollection('ft:17ZWOtlTiq6ehKrp8KhmDhsxwP0lVKHaGYaJqo_Uj');

//generate point and dates
var start = ee.Date('1994-01-01');
var finish = ee.Date('2017-01-01');
var daily = ee.ImageCollection('UCSB-CHG/CHIRPS/DAILY')
.filterDate(start, finish);


var mapfunc = function(feat) {
var geom = feat.geometry()
var addProp = function(img, f) {

var newf = ee.Feature(f)
var date = img.date().format("MM_dd_YYYY")
var value = img.reduceRegion(ee.Reducer.first(), geom,
30).get('precipitation')
return ee.Feature(ee.Algorithms.If(value,
newf.set(date, ee.String(value)),
newf.set(date, ee.String('No data'))))
}
var newfeat = ee.Feature(daily.iterate(addProp, feat))
return newfeat

};

var newft = fg_points.map(mapfunc);


Export.table.toDrive(newft,
"PrecipitationHTL",
"PrecipitationHTL",
"PrecipitationHTL");


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...