FORMA 是以 MODIS 為基礎的系統,可針對潮濕熱帶森林,每半個月提供一次 500 x 500 公尺的森林砍伐警報。Earth Engine 中的 FORMA 500 資料集是包含 2006 年 1 月起警報的圖片,每月更新一次。每個快訊都有相關聯的時間,以 紀元秒數為單位,並以名為 alert_date
的單一頻帶表示。使用 FORMA 資料集時,最重要的兩件事就是依日期篩選 FORMA,以及計算感興趣區域內的警示。
依日期篩選 FORMA
如要只顯示 2012 年發生的快訊,請找出時間介於 2012 年第一天和 2013 年第一天之間的像素,以自 1970 年 1 月 1 日午夜起經過的秒數表示:
程式碼編輯器 (JavaScript)
// Convert dates from milliseconds to seconds. var start = ee.Date('2012-01-01').millis().divide(1000); var end = ee.Date('2013-01-01').millis().divide(1000); // Load the FORMA 500 dataset. var forma = ee.Image('FORMA/FORMA_500m'); // Create a binary layer from the dates of interest. var forma2012 = forma.gte(start).and(forma.lte(end)); Map.setCenter(15.87, -0.391, 7); Map.addLayer( forma2012.mask(forma2012), {palette: ['FF0000']}, 'FORMA alerts in 2012' );
在本例中,forma2012
是二進位圖片,只包含 2012 年發生的時間 (即遮蓋所有其他像素)。
計算感興趣區域的 FORMA 警報
如同我們在上一節中處理 Hansen 等人的資料,我們可以先計算感興趣區域中的 FORMA 警示 (像素) 數量。舉例來說,如要計算 2012 年剛果共和國受保護區域的警報數量,請以前述範例為基礎,建構下列查詢:
程式碼編輯器 (JavaScript)
// Load country features from Large Scale International Boundary (LSIB) dataset. var countries = ee.FeatureCollection('USDOS/LSIB_SIMPLE/2017'); // Subset the Congo Republic feature from countries. var congo = ee.Feature( countries .filter(ee.Filter.eq('country_na', 'Rep of the Congo')) .first() ); // Subset protected areas to the bounds of the congo feature // and other criteria. Clip to the intersection with congo. var protectedAreas = ee.FeatureCollection('WCMC/WDPA/current/polygons') .filter(ee.Filter.and( ee.Filter.bounds(congo.geometry()), ee.Filter.neq('IUCN_CAT', 'VI'), ee.Filter.neq('STATUS', 'proposed'), ee.Filter.lt('STATUS_YR', 2010) )) .map(function(feat){ return congo.intersection(feat); }); // Display protected areas on the map. Map.addLayer( protectedAreas, {color: '000000'}, 'Congo Republic protected areas' ); // Calculate the number of FORMA pixels in protected // areas of the Congo Republic, 2012. var stats = forma2012.reduceRegion({ reducer: ee.Reducer.sum(), geometry: protectedAreas.geometry(), scale: 500 }); print('Number of FORMA pixels, 2012: ', stats.get('constant'));
計算多個感興趣區域的 FORMA 快訊
到目前為止,我們一次只會在一個區域中計算統計資料。如要一次計算多個區域的統計資料,可以使用 reduceRegions()
。再次以前述範例為基礎:
程式碼編輯器 (JavaScript)
var regionsStats = forma2012.reduceRegions({ collection: protectedAreas, reducer: ee.Reducer.sum(), scale: forma2012.projection().nominalScale() }); print(regionsStats);
檢查列印到控制台的物件,並觀察 reduceRegions()
的輸出內容是否為另一個 FeatureCollection
。請注意,剛果共和國受保護區域集合中的每個區域現在都有額外屬性,即以縮減器命名的 sum
。這個屬性的值是 reducer 的輸出內容,或是受保護區域中 2012 年警報的數量。
比較 FORMA 和 Hansen 等人的資料集
如要比較 FORMA 和 Hansen 等人的資料集,可以使用邏輯運算子。 (進一步瞭解邏輯運算)。具體來說,我們希望建立的圖片中,FORMA 和 Hansen 等人資料標示為森林砍伐的像素為 1,其餘像素為 0。這段程式碼會為 2012 年製作這類圖片,並與其他預測森林砍伐圖層一併顯示:
程式碼編輯器 (JavaScript)
// Convert dates from milliseconds to seconds. var start = ee.Date('2012-01-01').millis().divide(1000); var end = ee.Date('2013-01-01').millis().divide(1000); var region = ee.Geometry.Rectangle([-59.81163, -9.43348, -59.27561, -9.22818]); // Load the FORMA 500 dataset. var forma = ee.Image('FORMA/FORMA_500m'); // Create a binary layer from the dates of interest. var forma2012 = forma.gte(start).and(forma.lte(end)); // Load Hansen et al. data and get change in 2012. var gfc = ee.Image('UMD/hansen/global_forest_change_2015'); var gfc12 = gfc.select(['lossyear']).eq(12); // Create an image which is one where the datasets // both show deforestation and zero elsewhere. var gfc_forma = gfc12.eq(1).and(forma2012.eq(1)); // Display data on the map. Map.setCenter(-59.58813, -9.36439, 11); Map.addLayer(forma.updateMask(forma), {palette: '00FF00'}, 'Forma (green)'); Map.addLayer(gfc12.updateMask(gfc12), {palette: 'FF0000'}, 'Hansen (red)'); Map.addLayer( gfc_forma.updateMask(gfc_forma), {palette: 'FFFF00'}, 'Hansen & FORMA (yellow)' );
以上就是 Earth Engine 森林變化資料集的總覽。我們很期待看到你如何運用這些功能!