標(biāo)記特定像素
主要功能
獲取一特定時間段內(nèi)所有數(shù)據(jù)的集合,計算所有數(shù)據(jù)的中值,篩選矢量數(shù)據(jù),完成數(shù)據(jù)裁剪
代碼
// Composite an image collection and clip it to a boundary.
// Load Landsat 7 raw imagery and filter it to April-July 2000.
var collection = ee.ImageCollection('LANDSAT/LE07/C01/T1')
.filterDate('2000-04-01', '2000-07-01');
// Reduce the collection by taking the median.
var median = collection.median();
// Load a table of state boundaries and filter.
var fc = ee.FeatureCollection('TIGER/2016/States')
.filter(ee.Filter.or(
ee.Filter.eq('NAME', 'Nevada'),
ee.Filter.eq('NAME', 'Arizona')));
// Clip to the output image to the Nevada and Arizona state boundaries.
var clipped = median.clipToCollection(fc);
// Display the result.
Map.setCenter(-110, 40, 5);
var visParams = {bands: ['B3', 'B2', 'B1'], gain: [1.4, 1.4, 1.1]};
Map.addLayer(clipped, visParams, 'clipped composite');
步驟分析
- 生成數(shù)據(jù)集對象,使用數(shù)據(jù)名稱來加載特定數(shù)據(jù)
- 計算數(shù)據(jù)集中值
- 創(chuàng)建特征數(shù)據(jù)集對象,使用數(shù)據(jù)名稱加載數(shù)據(jù)
- 使用特征名稱來篩選數(shù)據(jù)集,獲取矢量邊界
- 裁剪數(shù)據(jù)集
- 設(shè)置地圖中心,縮放等級
- 設(shè)置圖層顯示參數(shù)
- 加載圖層,重命名圖層
主要方法
- ee.ImageCollection()
ImageCollections can be constructed from the following arguments:
- A string: assumed to be the name of a collection,
- A list of images, or anything that can be used to construct an image.
- A single image.
- A computed object - reinterpreted as a collection.
Arguments:
args (ComputedObject|Image|List<Object>|String):
The constructor arguments.
Returns: ImageCollection
創(chuàng)建影像數(shù)據(jù)集。影像數(shù)據(jù)集可以使用四種參數(shù)來創(chuàng)建,字符串(數(shù)據(jù)集名稱),列表(圖像的列表,或者可以創(chuàng)建圖像的列表),單獨的一幅影像,計算結(jié)果(轉(zhuǎn)換為數(shù)據(jù)集)
輸入?yún)?shù):創(chuàng)建影像數(shù)據(jù)集對象參數(shù)
- ee.ImageCollection.median()
Reduces an image collection by calculating the median of all values at each pixel across the stack of all matching bands. Bands are matched by name.
Arguments:
this:collection (ImageCollection):
The image collection to reduce.
Returns: Image
計算影像數(shù)據(jù)集的中值
輸入?yún)?shù):影像數(shù)據(jù)集
- ee.FeatureCollection()
FeatureCollections can be constructed from the following arguments:
- A string: assumed to be the name of a collection.
- A single geometry.
- A single feature.
- A list of features.
- A computed object: reinterpreted as a collection.
Arguments:
args (ComputedObject|Feature|FeatureCollection|Geometry|List<Object>|Number|String):
The constructor arguments.
column (String, optional):
The name of the geometry column to use. Only useful with constructor type 1.
Returns: FeatureCollection
創(chuàng)建一個要素數(shù)據(jù)集,可以使用五種參數(shù)來創(chuàng)建:符串(數(shù)據(jù)集名稱),單獨的一個地理對象,單獨的一個要素,要素列表,計算結(jié)果(轉(zhuǎn)換為數(shù)據(jù)集)
輸入?yún)?shù):影像數(shù)據(jù)集,屬性列表
- ee.Image.clipToCollection()
Clips an image to a FeatureCollection. The output bands correspond exactly the input bands, except data not covered by the geometry of at least one feature from the collection is masked. The output image retains the metadata of the input image.
Arguments:
this:input (Image):
The image to clip.
collection (Object):
The FeatureCollection to clip to.
Returns: Image
影像按照要素集進行裁切。輸入?yún)?shù):影像對象,要素集(裁切邊界)