0

我根据 MCD43A4(空间分辨率 500m)集合计算了存在各种水体的区域的 NDMI 指数。我想做的是根据 Landsat Global Inland Water 数据集(空间分辨率 30m)从我的收藏中掩盖这些水体,但我不知道如何做到这一点。我必须做的第一件事是改变 Landsat 的空间分辨率以使其与 MODIS 匹配,但我不明白如何做到这一点,我应该使用一种 Reduce 吗?

谢谢

var geometry = /* color: #d63000 */ee.Geometry.Polygon(
        [[[69.75758392503599, 50.151303763817786],
          [71.60328705003599, 40.18192251959151],
          [93.70777923753599, 41.54446477874571],
          [91.86207611253599, 51.09912927236651]]]);
var dataset = ee.ImageCollection('GLCF/GLS_WATER')
.filterBounds(geometry)
    .map(function(image){return image.clip(geometry)}) ;
var water = dataset.select('water');
var imageCollection = ee.ImageCollection("MODIS/006/MCD43A4")
 .filterBounds(geometry)
    .map(function(image){return image.clip(geometry)}) 
    .filter(ee.Filter.calendarRange(6,8,'month'));
   var modNDMI = imageCollection.select("Nadir_Reflectance_Band2","Nadir_Reflectance_Band6","BRDF_Albedo_Band_Mandatory_Quality_Band2","BRDF_Albedo_Band_Mandatory_Quality_Band6");
/////////////////////////////////////////////////

var quality = function(image){ 
  var mask1 = image.select("BRDF_Albedo_Band_Mandatory_Quality_Band2").eq(0);
  var mask2 = image.select("BRDF_Albedo_Band_Mandatory_Quality_Band6").eq(0);
  return image.updateMask(mask1).updateMask(mask2);
};

var clean_collection = modNDMI.map(quality);

var addNDMI = function(image) {
  var ndmi = image.normalizedDifference(['Nadir_Reflectance_Band2', 'Nadir_Reflectance_Band6']).rename('NDMI');
  return image.addBands(ndmi);
};
var ndmi = clean_collection.map(addNDMI);

var NDMI=ndmi.select('NDMI')
print(water)
//And from this point, I have no idea how to mask the water bodies based on the
//Landsat collection
4

1 回答 1

1

It's not entirely obvious what you mean by "mask the waterbodies," but if this is not what you intend, then just use water_mask.not().

var gsw = ee.Image('JRC/GSW1_0/GlobalSurfaceWater');
var occurrence = gsw.select('occurrence');
// Create a water mask layer, and set the image mask so that non-water areas
// are opaque.
var water_mask = occurrence.gt(90).unmask(0);
Map.addLayer(water_mask)

var dataset = ee.ImageCollection('GLCF/GLS_WATER')
var water = dataset.select('water');

var imageCollection = ee.ImageCollection("MODIS/006/MCD43A4")
    .filterDate('2017-01-01', '2018-12-31')
    .filter(ee.Filter.calendarRange(6,8,'month'));
var modNDMI = imageCollection.select("Nadir_Reflectance_Band2","Nadir_Reflectance_Band6","BRDF_Albedo_Band_Mandatory_Quality_Band2","BRDF_Albedo_Band_Mandatory_Quality_Band6");

var quality = function(image){ 
  var mask1 = image.select("BRDF_Albedo_Band_Mandatory_Quality_Band2").eq(0);
  var mask2 = image.select("BRDF_Albedo_Band_Mandatory_Quality_Band6").eq(0);
  return image.updateMask(mask1).updateMask(mask2);
};

var clean_collection = modNDMI.map(quality);

var addNDMI = function(image) {
  var ndmi = image.normalizedDifference(['Nadir_Reflectance_Band2', 'Nadir_Reflectance_Band6']).rename('NDMI');
  return image.addBands(ndmi).updateMask(water_mask);
};
var ndmi = clean_collection.map(addNDMI);

var NDMI=ndmi.select('NDMI')
Map.addLayer(NDMI)

See also this tutorial.

于 2019-03-15T21:44:46.917 回答