1

I'm trying to calculate this formula in GEE:

∑ U(U-5)^2 (u is wind speed greater than 5)

when I use (.add) in my code it just give me a pixels that are greater than 5 in both of them at the same but maybe in first image in one pixel we don't have wind greater than 5 but in other we have, I want one image that have all of them at the same time:

var Windspeed = ee.ImageCollection('NASA/GLDAS/V021/NOAH/G025/T3H')
.filter(ee.Filter.date('2020-01-01'))
.select('Wind_f_inst')
.mean();

var gt = Windspeed.gt(5);
var  u = Windspeed.mask(gt); 

var Windspeed1 = ee.ImageCollection('NASA/GLDAS/V021/NOAH/G025/T3H')
.filter(ee.Filter.date('2020-01-02'))
.select('Wind_f_inst')
.mean();

var gt1 = Windspeed1.gt(5);
var  u1 = Windspeed1.mask(gt1); 
  
var windt = u.add(u1)  



var WindVis = {
  min: 46.05683272577041,
  max: 101.32877871485076,
  palette: ['1303ff', '42fff6', 'f3ff40', 'ff5d0f'],
};


Map.centerObject(table);
Map.addLayer(
    windt.clip(table), WindVis,
    'U2');

1 Answer 1

1

I'm not sure I understood what you're asking, but I think you want to mask out pixels where both windspeeds are below 5.

var mask = Windspeed.gt(5).or(Windspeed1.gt(5))
var u = Windspeed.updateMask(mask)
var u1 = Windspeed1.updateMask(mask)
var windt = u.add(u1)

https://code.earthengine.google.com/7e51711467144c7479fa1302f2cf917f

1
  • This is what I wanted, but if i want use this code for many days what should I do? its hard to write for 30 days Actually i want run this code for 01/01/2020 to 30/01/2020
    – Sajjad
    Commented Dec 10, 2022 at 8:15

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.