Following the previous question, I have a new question. From the following code, I estimate the water areas for selected regions in Google Earth Engine. However, as you could see from the second line of the code, it only estimates for selected date (.filterDate("2010-03-01");
). I want it to estimate for all the available dates (months in the dataset) and the regions. Shortly, I would like to add a simple loop for the dates in this code.
//Opening the JRC Water Data
var water_data = ee.ImageCollection("JRC/GSW1_2/MonthlyHistory").filterDate("2010-03-01");
var water_area = ee.Image(water_data.first())
//Creating Region Variable
var turkeyProvinces = ee.FeatureCollection("FAO/GAUL_SIMPLIFIED_500m/2015/level1")
.filter(ee.Filter.eq("ADM0_NAME", "Turkey"));
//Calculating Water Areas
var calculateClassArea = function(feature) {
var areas = water_area.eq(2).selfMask().multiply(ee.Image.pixelArea()).divide(1e6)
.reduceRegion({
reducer: ee.Reducer.sum(),
geometry: feature.geometry(),
scale: 30,
maxPixels: 1e10
})
return feature.set(areas)
}
var waterAreas = turkeyProvinces.map(calculateClassArea);
//Exporting the Results
Export.table.toDrive({
collection: waterAreas,
description: 'water_area_by_province',
folder: 'earthengine',
fileNamePrefix: 'water_area_by_province',
fileFormat: 'CSV',
selectors: ['ADM1_NAME', 'water']
})
Here is the Google Earth Engine link: https://code.earthengine.google.com/f024358da930db6444ea29820867a7dd