目录
normalizedDifference(bandNames)
简介
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, description, folder, fileNamePrefix, dimensions, region, scale, crs, crsTransform, maxPixels, shardSize, fileDimensions, skipEmptyTiles, fileFormat, formatOptions, priority)
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'
})