目录

简介

NDWI指数

函数

ee.Image.pixelArea()

No arguments.

Returns: Image

reduceRegion(reducer, geometry, scale, crs, crsTransform, bestEffort, maxPixels, tileScale)

Arguments:

Returns: Dictionary

代码

结果


简介

这里我们进行影像的水域面积计算,这里出了影像预处理后,最主要的过程就是如何进行像素面积计算,另外,如何利用统计函数来进行sum来统计整个像素内的面积是多少。

NDWI指数

NDWI指数,全称为归一化差异水体指数(Normalized Difference Water Index),是一种用于遥感图像分析中水体检测和提取的指数。NDWI指数利用了绿光和近红外波段反射率之间的差异来区分水体和陆地。公式如下:

NDWI = (Green - NIR) / (Green + NIR)

其中,Green代表绿光波段的反射率,NIR代表近红外波段的反射率。

NDWI值的范围从-1到1,较高的值表示像素更有可能是水体,较低的值则表示更有可能是陆地。一般来说,NDWI值大于0.3被认为是水体,而小于0.3被认为是陆地。

NDWI指数广泛应用于水体监测、湖泊监测、洪水监测、冰川监测等领域,对于全球水资源管理和环境研究具有重要意义。

函数

ee.Image.pixelArea()

Generate an image in which the value of each pixel is the area of that pixel in square meters. The returned image has a single band called "area."

生成一个图像,其中每个像素的值是该像素的面积(单位为平方米)。返回的图像有一个名为“区域”的波段。"

No arguments.

Returns: Image

reduceRegion(reducer, geometryscalecrscrsTransformbestEffortmaxPixelstileScale)

Apply a reducer to all the pixels in a specific region.

Either the reducer must have the same number of inputs as the input image has bands, or it must have a single input and will be repeated for each band.

Returns a dictionary of the reducer's outputs.

对特定区域中的所有像素应用缩减器。

缩减器的输入数量必须与输入图像的频段相同,或者必须有一个输入并且将为每个频段重复。

返回缩减器输出的字典。

Arguments:

this:image (Image):

The image to reduce.

reducer (Reducer):

The reducer to apply.

geometry (Geometry, default: null):

The region over which to reduce data. Defaults to the footprint of the image's first band.

scale (Float, default: null):

A nominal scale in meters of the projection to work in.

crs (Projection, default: null):

The projection to work in. If unspecified, the projection of the image's first band is used. If specified in addition to scale, rescaled to the specified scale.

crsTransform (List, default: null):

The list of CRS transform values. This is a row-major ordering of the 3x2 transform matrix. This option is mutually exclusive with 'scale', and replaces any transform already set on the projection.

bestEffort (Boolean, default: false):

If the polygon would contain too many pixels at the given scale, compute and use a larger scale which would allow the operation to succeed.

maxPixels (Long, default: 10000000):

The maximum number of pixels to reduce.

tileScale (Float, default: 1):

A scaling factor between 0.1 and 16 used to adjust aggregation tile size; setting a larger tileScale (e.g., 2 or 4) uses smaller tiles and may enable computations that run out of memory with the default.

Returns: Dictionary

代码

var coordinates = [
  [42.000552219688586, 38.18969302118053],
  [43.868228000938586, 38.18969302118053],
  [43.868228000938586, 39.209978258633186],
  [42.000552219688586, 39.209978258633186],
  [42.000552219688586, 38.18969302118053]
];

var roi = ee.Geometry.Polygon(coordinates);

Map.addLayer(roi)

var time_start = '2023', time_end = '2024'

var landsat = ee.ImageCollection("LANDSAT/LC08/C02/T1_L2")
.filterDate(time_start, time_end)
.filter(ee.Filter.lt('CLOUD_COVER', 10))
.filter(ee.Filter.calendarRange(6,9,'month'))
.filterBounds(roi).map(function(img){
  var bands = img.select('SR_.*').multiply(2.75e-05).add(-0.2);
  var ndwi = bands.normalizedDifference(['SR_B3','SR_B5']).rename('ndwi');
  return ndwi
  .copyProperties(img, img.propertyNames())
  }).median();


Map.addLayer(landsat.clip(roi), [], 'ndwi_summer', false);
Map.addLayer(landsat.clip(roi).gt(0), [], 'ndwi_thr', false);

var thr = landsat.gt(0.1);
var mask = thr.updateMask(thr);

Map.addLayer(mask, [], 'ndwi_masked', false);


var pixel_area = mask.multiply(ee.Image.pixelArea().divide(1e6));

Map.addLayer(pixel_area.clip(roi), [], 'ndwi_pixel_area', false);

var lake_area = pixel_area.reduceRegion({
  reducer: ee.Reducer.sum(), geometry: roi, scale: 100
  }).values().get(0);
  
  
print(ee.Number(lake_area))

结果

GEE 案例:如何利用Landsat 8 数据和NDWI指数来计算指定区域的水域面积_Image