I am trying to extract monthly PRISM ppt values over 58 polygons for 1 year. I am able to extract the values for one month (image), but when I try to map over the entire image collection, the result has zero columns. Code is adapted from a previous post on a similar issue (Daily Rainfall data extraction from CHIRPS database for polygons using Google Earth Engine). When I run the code from the previous post I also receive an output with zero columns. Any ideas what is driving this error?
var imgcol = ee.ImageCollection('OREGONSTATE/PRISM/AN81m'),
catchm = ee.FeatureCollection("users/Ctester14/all_catchments")
//Set Time Period
var img_col = imgcol.filter(ee.Filter.date ('2012-01-01', '2012-12-30'));
var image = img_col.first()
//deriving the date of the image
var date= image.get('system:index')
//zonal statistics
var mean_rain = function (feature){
var rain = image.reduceRegion({
reducer: ee.Reducer.mean(),
geometry: feature.geometry(),
scale: 4000, //the PRISM dataset has 4K degree resolution
});
var sdis_rain = feature.set('Mean Rainfall', rain.get('ppt'))
.set ("Date", date);
return sdis_rain;
};
//running the function for all features in the shapefile
var rainfall = catchm.map(mean_rain);
print (rainfall);
/*
Export.table.toDrive ({
collection: rainfall,
description: 'Mean Rain',
selectors: ['Dscrptn', 'Date', 'Mean Rainfall']
})
*/
// Run across all dates as well as features
var totalOutput = ee.ImageCollection(img_col).map(function(image){
//deriving the date of the image
var date= image.get('system:index')
var test = catchm.map(function(feature){
var rain = image.reduceRegion({
reducer: ee.Reducer.mean(),
geometry: feature.geometry(),
scale: 4000,
});
return ee.Feature(feature.set('MeanRain', rain.get('ppt'))
.set ("Date", date))
})
return ee.FeatureCollection(test);
}).flatten()
print(totalOutput.limit(10))
Collection.loadTable: Collection asset 'users/Ctester14/all_catchments' not found.