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.



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');


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)

  image: image,
  description: 'Nieve23',
  //Folder: SWE_DayMet,
  //band: "swe",
  region: z6,
  scale: 500,
  maxPixels: 1e13


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.