var dataset = ee.ImageCollection('LANDSAT/LC09/C02/T1_L2')
.filterDate('202-01-01', '2023-01-03')
.filterBounds(geometry);
var image = dataset.median()
.clip(geometry);
var NIR = image.select('SR_B5').multiply(0.0000275).add(-0.2);
var R = image.select('SR_B4').multiply(0.0000275).add(-0.2);
var ndvi = (NIR.subtract(R)).divide(NIR.add(R));
Map.addLayer(ndvi, {min:0 , max:1 , palette:\[
'FFFFFF', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718', '74A901',
'66A000', '529400', '3E8601', '207401', '056201', '004C00', '023B01',
'012E01', '011D01', '011301'\]});
var ndvi_mean=ndvi .reduceRegion({
reducer:ee.Reducer.mean(),
geometry: geometry
});
print(ndvi_mean)
Map.setCenter(121.14165687106332,16.481598264423443, 16);
//Notes: //NIR band = SR_B5, min = 1, max = 65455, Scale = 2.75e-05, Offset = -0.2, WV = 0.851-0.879 μm, Desc = Band 5 (near infrared) surface reflectance ///R band = SR_B4, min = 1, max = 65455, Scale = 2.75e-05, Offset = -0.2, WV = 0.636-0.673 μm, Desc = Band 4 (red) surface reflectanc
I was trying to compute the average NDVI value within a specific area of interest through geometry in Google Earth Engine.
I am new to this so I applied scripts online and tried also to create a script to get the average value of NDVI. It was successful to display the NDVI but not the average. If you hover and click through the generated map/layer, different values are displayed, not the average NDVI of that area of interest