We now need to reclassify the dataset to snow, non-snow, or missing. Luckily, GEE has a remap function, which takes a list of inputs and changes the values to those you specify. If you search the documentation, remap methods exist for both images and image collections. We want the images version because we want to keep the missing values, not drop them from the collection. This means we can use the handy .map() method again.
Looking at the coded values from the MOD10A1 documentation above, we want to turn all the values that represent “snow” to a value of 1, and all the values that represent “No snow” to a value of 0. Anything that doesn’t fall within those parameters will result in a value of null, for 'missing'. The code should look something like this:
If you noticed, we are also at the end of our first processing chain, "Prepare MODIS Snow cover." This means we can wrap up all of the previous steps into a single function that takes two dates, a StartDate and a StopDate.
Now that we have that function done, it is time to calculate snow cover frequency.