前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >GEE 案例:如何利用Landsat 8 数据和NDWI指数来计算指定区域的水域面积

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

作者头像
此星光明
发布2024-09-13 11:23:15
1990
发布2024-09-13 11:23:15
举报

简介

这里我们进行影像的水域面积计算,这里出了影像预处理后,最主要的过程就是如何进行像素面积计算,另外,如何利用统计函数来进行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, geometry, scale, crs, crsTransform, bestEffort, maxPixels, tileScale)

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

代码

代码语言:javascript
复制
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))

结果

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2024-09-12,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 简介
  • NDWI指数
  • 函数
    • ee.Image.pixelArea()
      • No arguments.
      • Returns: Image
    • reduceRegion(reducer, geometry, scale, crs, crsTransform, bestEffort, maxPixels, tileScale)
      • Arguments:
      • Returns: Dictionary
  • 代码
  • 结果
相关产品与服务
图像识别
腾讯云图像识别基于深度学习等人工智能技术,提供车辆,物体及场景等检测和识别服务, 已上线产品子功能包含车辆识别,商品识别,宠物识别,文件封识别等,更多功能接口敬请期待。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档