天天看點

GEE基礎學習——影像集合裁剪

當你使用一個影像集合的資料,而且有想按照自己的研究區域進行裁剪,但發現很多時候直接再後面.clip()無法進行裁剪,那麼很大程度上是應為影像集合的裁剪對應的是矢量集合的裁剪,而不是單張影像,是以會出現錯誤。今天給大家利用GEE線上多個矢量集合裁剪案例:

用的資料是Landsat7資料,美國的兩個州進行。

直接上代碼:

// 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.
//裁剪已經編輯好的fc矢量邊界
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');      

最後圖形結果:

GEE基礎學習——影像集合裁剪

繼續閱讀