Skip to content

Commit

Permalink
Update Terrestrial vegetation classification
Browse files Browse the repository at this point in the history
  • Loading branch information
charlotte-walshaw authored May 23, 2024
1 parent 8813911 commit ad95cbb
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Terrestrial vegetation classification
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,22 @@ var green_veg = function(image){
return image.updateMask(veg_indices)};
var greenVeg = indices.map(green_veg);

// Add green layer as a band, so that it can be masked before detecting lichens (to prevent inevitable instances of overlap between green veg and lichen pixels)
// Add green layer as a band, so that it can be masked before detecting lichens (to prevent any instances of overlap between green veg and lichen pixels)
var GreenVegBand = function(image){
var band = image.select('NDVI').gt(0.4)
.and(image.select('NDVI').lt(0.98))
.and(image.select('NDMI').gt(-0.2))
.and(image.select('NDMI').lt(0.6)).rename('GreenVegMask').toFloat(); // 'GreenVegMask' is the new band applied to all images for the green veg layer
return image.addBands(band)};
var GreenVegMask1 = indices.map(GreenVegBand); // Green vegetation is detected first on the reasoning that if pixel reflectance reaches NDVI > 0.4, it is more likely to be green vegetation
var GreenVegMask1 = indices.map(GreenVegBand); // Green vegetation is detected first because pixel NDVI values which can reach values > 0.4 are more likely to be green vegetation

// The 'GreenVegMask' band is binary (green veg = 1, everything else = 0). To prevent 'everything else' from being masked when masking the green veg, remove the 0 by adding a random number (e.g. 4 in this case) to the GreenVegMask band
// The new 'GreenVegMask' band is binary (green veg = 1, everything else = 0). To prevent 'everything else' from being masked when masking the green veg, remove the 0 from the GreenVegMask band
var RemoveZero = function(image){
var masking = image.select('GreenVegMask').add(4).rename('GreenVegMask_1').toFloat();
return image.addBands(masking)};
var GreenVegMask = GreenVegMask1.map(RemoveZero); // Now the GreenVegMask band for green veg = 5, and everything else = 4
var GreenVegMask = GreenVegMask1.map(RemoveZero);

// Mask the green vegetation layer using a mean composite (the latter standardises all green veg mask band values for pixels detected at least once as green vegetation)
// Mask the green vegetation layer using a mean composite (the latter harmonizes all green veg mask band values for pixels detected at least once as green vegetation)
var mean = GreenVegMask.reduce(ee.Reducer.mean()); // code is looking through all temporal images before masking green vegetation - so had chance to detect under variability

// Lichen detection thresholding
Expand Down

0 comments on commit ad95cbb

Please sign in to comment.