I'm trying to calculate the fraction of snow cover and compare it to a time series. For this I need the total number of pixels with and without snow in an area of interest. I can get this # of pixels for one day, but I can't do it for a longer period like in a time series.
I leave here the code that I am using.
https://code.earthengine.google.com/4f04d770b3dfa9036a7a4a427cee3a94
Map.centerObject(z6);
Map.addLayer(z6);
var modis = ee.ImageCollection('MODIS/006/MYD10A1');
var mod11a2 = modis.filterDate( '2016-01-01', '2017-03-01'); //'2023-02-25'
var modLSTday = mod11a2.select('NDSI_Snow_Cover');
print(modLSTday);
var allDates = modLSTday.aggregate_array('system:time_start');
var allDates = allDates.map(function(date){
return ee.Date(date).format().slice(0,10);
});
print("allDates", allDates);
var snowCoverVis = {
min: 0.0,
max: 100.0,
palette: ['black', '0dffff', '0524ff', 'ffffff'],
};
var snowcover_lst = modLSTday.toList(modLSTday.size());
var image = ee.Image(ee.List(snowcover_lst).get(359)); // EL número ".get (151) significa el # de imagen en la colección
var c = image.reduceRegion({
reducer: ee.Reducer.count(),
geometry: z6
});
print("numero de pixeles como nieve", c);
var image2 = ee.Image(ee.List(snowcover_lst).get(359));
var count = image2.reduceRegion({
reducer: ee.Reducer.count(),
geometry: z6, // subtract half the scale from geometry
scale: 500,
maxPixels: 1e9
})
print("numero de pixeles de Z6", count)
Export.image.toDrive({
image: image,
description: 'Nieve23',
//Folder: SWE_DayMet,
//band: "swe",
region: z6,
crs:'EPSG:4326',
scale: 500,
maxPixels: 1e13
});