I am trying to set the null values of NDVI to zero for districts in Indonesia. However, when I export the table, the mean value for all districts come up as zero, which is not correct. Is there a way to correctly export the mean value for all districts, whilst setting the value of null to be zero? Here is my attempt at the code:
var districtsindo = shp4.select('NAME_3');
var water_district = Ndvi.reduceRegions({
collection:districtsindo,
reducer:ee.Reducer.mean(),
scale:30,
})
function removegeo(feature) {
var meanvalue=feature.get('mean')
if (ee.Number(meanvalue).eq(null)){
feature = feature.set({'mean': 0})
}
feature = feature.setGeometry(null);
return feature
}
var water_district = water_district.map(removegeo);
Export.table.toDrive({
collection:water_district,
description: 'Tablebydistrict',
fileFormat: 'CSV'
});