首页 > 其他分享 >GEE教程:利用sentinel-2数据进行ndwi和ndci指数的计算和下载

GEE教程:利用sentinel-2数据进行ndwi和ndci指数的计算和下载

时间:2024-09-22 13:52:46浏览次数:11  
标签:ndci bands image var GEE sentinel NIR folder optional

目录

简介

函数

normalizedDifference(bandNames)

Arguments:

Returns: Image

Export.image.toDrive(image, description, folder, fileNamePrefix, dimensions, region, scale, crs, crsTransform, maxPixels, shardSize, fileDimensions, skipEmptyTiles, fileFormat, formatOptions, priority)

Arguments:

代码

结果


简介

NDWI(Normalized Difference Water Index,归一化差异水体指数)和NDCI(Normalized Difference Chlorophyll Index,归一化差异叶绿素指数)都是一种利用遥感影像数据来评估特定地物或地表类型的指数。

1. 归一化差异水体指数(NDWI):
   NDWI用于识别和区分水体和陆地。它基于水体对近红外(NIR)波段和短波红外(SWIR)波段辐射的反射率差异。其计算公式为:
   NDWI = (NIR - SWIR) / (NIR + SWIR)
   其中,NIR代表近红外波段的反射率,SWIR代表短波红外波段的反射率。
   NDWI的取值范围为-1到1,较高的数值表示较多的水体存在,较低的数值表示较多的陆地存在。

2. 归一化差异叶绿素指数(NDCI):
   NDCI用于评估和监测植被的叶绿素含量和生理状态。它基于植被对近红外(NIR)波段和红色(RED)波段辐射的反射率差异。其计算公式为:
   NDCI = (NIR - RED) / (NIR + RED)
   其中,NIR代表近红外波段的反射率,RED代表红色波段的反射率。
   NDCI的取值范围为-1到1,较高的数值表示较高的叶绿素含量(通常与较茂盛的植被相关),较低的数值表示较低的叶绿素含量(通常与植被稀疏或受到胁迫的区域相关)。

这些指数可以通过遥感影像数据计算得出,并可以用于水资源管理、环境监测、植被健康评估等应用领域。

函数

normalizedDifference(bandNames)

Computes the normalized difference between two bands. If the bands to use are not specified, uses the first two bands. The normalized difference is computed as (first − second) / (first + second). Note that the returned image band name is 'nd', the input image properties are not retained in the output image, and a negative pixel value in either input band will cause the output pixel to be masked. To avoid masking negative input values, use ee.Image.expression() to compute normalized difference.

计算两个频段之间的标准化差。如果未指定要使用的频段,则使用前两个频段。标准化差计算为(第一-秒)/(第一+秒)。请注意,返回的图像频段名称为“nd”,输入图像属性不会保留在输出图像中,并且任何输入频段中的负像素值都将导致输出像素被屏蔽。为了避免掩盖负输入值,请使用ee.Image. express()来计算规格化差异。

Arguments:

this:input (Image):

The input image.

bandNames (List, default: null):

A list of names specifying the bands to use. If not specified, the first and second bands are used.

Returns: Image

Export.image.toDrive(image, descriptionfolderfileNamePrefixdimensionsregionscalecrscrsTransformmaxPixelsshardSizefileDimensionsskipEmptyTilesfileFormatformatOptionspriority)

Creates a batch task to export an Image as a raster to Drive. Tasks can be started from the Tasks tab. "crsTransform", "scale", and "dimensions" are mutually exclusive.

Arguments:

image (Image):

The image to export.

description (String, optional):

A human-readable name of the task. May contain letters, numbers, -, _ (no spaces). Defaults to "myExportImageTask".

folder (String, optional):

The Google Drive Folder that the export will reside in. Note: (a) if the folder name exists at any level, the output is written to it, (b) if duplicate folder names exist, output is written to the most recently modified folder, (c) if the folder name does not exist, a new folder will be created at the root, and (d) folder names with separators (e.g. 'path/to/file') are interpreted as literal strings, not system paths. Defaults to Drive root.

fileNamePrefix (String, optional):

The filename prefix. May contain letters, numbers, -, _ (no spaces). Defaults to the description.

dimensions (Number|String, optional):

The dimensions to use for the exported image. Takes either a single positive integer as the maximum dimension or "WIDTHxHEIGHT" where WIDTH and HEIGHT are each positive integers.

region (Geometry.LinearRing|Geometry.Polygon|String, optional):

A LinearRing, Polygon, or coordinates representing region to export. These may be specified as the Geometry objects or coordinates serialized as a string.

scale (Number, optional):

Resolution in meters per pixel. Defaults to 1000.

crs (String, optional):

CRS to use for the exported image.

crsTransform (List<Number>|String, optional):

Affine transform to use for the exported image. Requires "crs" to be defined.

maxPixels (Number, optional):

Restrict the number of pixels in the export. By default, you will see an error if the export exceeds 1e8 pixels. Setting this value explicitly allows one to raise or lower this limit.

shardSize (Number, optional):

Size in pixels of the tiles in which this image will be computed. Defaults to 256.

fileDimensions (List<Number>|Number, optional):

The dimensions in pixels of each image file, if the image is too large to fit in a single file. May specify a single number to indicate a square shape, or an array of two dimensions to indicate (width,height). Note that the image will still be clipped to the overall image dimensions. Must be a multiple of shardSize.

skipEmptyTiles (Boolean, optional):

If true, skip writing empty (i.e. fully-masked) image tiles. Defaults to false. Only supported on GeoTIFF exports.

fileFormat (String, optional):

The string file format to which the image is exported. Currently only 'GeoTIFF' and 'TFRecord' are supported, defaults to 'GeoTIFF'.

formatOptions (ImageExportFormatConfig, optional):

A dictionary of string keys to format-specific options. For 'GeoTIFF': 'cloudOptimized'

(Boolean), 'noData' (float). For 'TFRecord': see https://developers.google.com/earth-engine/guides/tfrecord#formatoptions

priority (Number, optional):

The priority of the task within the project. Higher priority tasks are scheduled sooner. Must be an integer between 0 and 9999. Defaults to 100.

代码

var cor = [-119.54665080086161,40.038023972187226]

var geometry = ee.Geometry.Point(cor)

var cor2 = [
  [-119.77142190684849,39.825295708288806],
  [-119.31274270762974,39.825295708288806],
  [-119.31274270762974,40.25006751768576],
  [-119.77142190684849,40.25006751768576],
  [-119.77142190684849,39.825295708288806]
  ]

var geometry2 = ee.Geometry.Polygon(cor2)

Map.centerObject(geometry2)


var sentinel = ee.ImageCollection("COPERNICUS/S2_SR_HARMONIZED")
.filterDate('2021-09-01','2021-10-01')
.filterBounds(geometry)
.filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE',45))
.map(function(img){
  var bands = img.select('B.*').multiply(0.0001)
  var ndwi = bands.normalizedDifference(['B3','B8']).rename('ndwi')
  var thr = ndwi.gt(0.1)
  var ndci = bands.normalizedDifference(['B5','B4']).rename('ndci')
  return ndci.updateMask(thr)
  .copyProperties(img,['system:time_start','system:time_end'])
  })

print(sentinel)

Map.addLayer(sentinel.toBands().clip(geometry2), [], 'ndci', false)


var target = sentinel.filterDate('2021-09-08','2021-09-09')

Map.addLayer(target.toBands().select([0]).clip(geometry2), [], 'ndci-target', false)


Export.image.toDrive({
  image: target.mean().clip(geometry2),
  description: 'ndci', 
  scale: 20, 
  region: geometry2, 
  maxPixels: 1e13, 
  crs: 'EPSG:4326',
  folder: 'Chlorophyll'
  })

结果

标签:ndci,bands,image,var,GEE,sentinel,NIR,folder,optional
From: https://blog.csdn.net/qq_31988139/article/details/142267418

相关文章

  • Redis哨兵机制sentinel集群配置
    一、安装redis1主2从集群略二、复制sentinel.conf文件到指定目录修改sentinel.conf配置port26379dir"/tmp"logfile"/usr/local/redis/logs/sentinel-26379.log"daemonizeyessentinelmonitormymaster10.211.55.763792sentinelauth-passmymasterlinlinsen......
  • GEE教程:对降水数据进行重投影(将10000m分辨率提高到30m)
    目录简介函数projection()Arguments:Returns: ProjectionnominalScale()Arguments:Returns: FloatsetDefaultProjection(crs, crsTransform, scale)Arguments:Returns: Image代码结果简介在GEE中进行重投影和重分类的步骤如下:1.选择目标图层。2.使用......
  • GEE教程:1950-2023年ECMWF数据中积雪的长时序统计分析
    目录简介数据函数millis()Arguments:Returns: Long代码结果简介1950-2023年ECMWF数据中积雪的长时序统计分析数据ECMWF/ERA5_LAND/DAILY_AGGR是由欧洲中期天气预报中心(ECMWF)提供的数据集。它是一个格网数据集,包含从ERA5-Land再分析数据集中得出的陆地区域每日聚......
  • 入门sentinel
    Sentinel是阿里巴巴开源的一款面向分布式服务架构的轻量级流量控制组件,主要用于保护微服务和分布式系统,防止因流量过大或服务故障导致系统崩溃。以下是对Sentinel入门的详细介绍:一、Sentinel的主要功能Sentinel是阿里巴巴开源的一款面向分布式服务架构的高可用流量防护......
  • GEE 案例:利用UCSB-CHG/CHIRPS/DAILY数据采用非监督分类实现某区域的降水区域的划分
    目录简介数据函数ee.Clusterer.wekaKMeans(nClusters, init, canopies, maxCandidates, periodicPruning, minDensity, t1, t2, distanceFunction, maxIterations, preserveOrder, fast, seed)Arguments:Returns: Clusterer代码结果简介利用UCSB-CHG......
  • GEE教程:利用NOAA/NDVI/V5数据实现长时序NDVI指数统计
    目录简介数据函数ee.Join.saveAll(matchesKey, ordering, ascending, measureKey, outer)Arguments:ee.Reducer.first()Noarguments.Returns: Reduceree.Filter.maxDifference(difference, leftField, rightValue, rightField, leftValue)Arguments:Retur......
  • GEE 案例:利用2001-2024年的MODIS数据长时序ndvi指数归一化后的结果分析
    目录简介指数数据代码结果简介利用2001-2024年的MODIS数据长时序ndvi指数归一化后的结果分析,并加载时序图。指数NDVI指数(NormalizedDifferenceVegetationIndex)是用来评估地表植被覆盖度和健康程度的指数。它通过计算红光和近红外光反射率的差异来衡量植被的光合......
  • GEE :利用MODIS土地分类数据监测指定区域2001-2024年农作物的时序面积
    目录简介数据函数ee.Image.pixelArea()Noarguments.Returns: Image代码结果简介利用MODIS土地分类数据监测指定区域2001-2024年农作物的时序面积数据MODIS/061/MCD12Q1是一个由美国国家航空航天局(NASA)和美国地质调查局(USGS)联合开发的遥感数据产品。它是MODIS(M......
  • GEE 案例:利用ECMWF数据进行1950-2024年长时序气温(平均值和标准差)监测和图表绘制
    目录简介数据函数propertyNames()Arguments:Returns: Listexpression(expression, map)Arguments:Returns: Image代码结果简介利用ECMWF数据进行1950-2024年长时序气温监测和图表绘制数据ECMWF(欧洲中期天气预报中心)的ERA5_LAND(第五代地表分析数据集)是一种......
  • 联网对话功能上线,CodeGeeX智能编程助手再度升级!
    CodeGeeX上线联网获取信息的新功能!进一步提升在编程场景中的实用性和智能水平。值得一提的是,联网对话这一创新功能,目前在编程工具的同类型产品中,是独一无二的。下面我们就来一起看看这一创新为开发者带来的价值,以及如何运用它来提升编程效率和问题解决的能力。首先,打开联网获取信息......