hansen數據集顯示森林變化

驚喜疑羞 2021-08-15 22:34:28 阅读数:245

本文一共[544]字,预计阅读时长:1分钟~
hansen 森林
var gfc2020 = ee.Image("UMD/hansen/global_forest_change_2020_v1_8")
Map.addLayer(gfc2020, {bands: ['treecover2000']}, 'Tree cover in 2000')
Map.addLayer(gfc2020, {bands: ['last_b50''last_b40''last_b30']}, 'False colour')
Map.addLayer(gfc2020, {bands: ['loss''treecover2000''gain']}, 'Green')
Map.addLayer(gfc2020, {
  bands: ['loss''treecover2000''gain'],
  max: [12551]
}, 'Forest cover, loss, gain')
Map.addLayer(gfc2020, {
  bands: ['treecover2000'],
  palette: ['000000''00FF00']
}, 'Forest cover palette')
Map.addLayer(gfc2020, {
  bands: ['treecover2000'],
  palette: ['000000''00FF00'],
  max100
}, 'Forest cover percent')
Map.addLayer(gfc2020.mask(gfc2020), {
  bands: ['treecover2000'],
  palette: ['000000''00FF00'],
  max100
}, 'Forest cover masked')

var treeCover = gfc2020.select(['treecover2000']);
var lossImage = gfc2020.select(['loss']);
var gainImage = gfc2020.select(['gain']);

// 綠色代錶森林覆蓋
Map.addLayer(treeCover.updateMask(treeCover),
    {palette: ['000000''00FF00'], max100}, 'Forest Cover')

// 紅色代錶損失
Map.addLayer(lossImage.updateMask(lossImage),
            {palette: ['FF0000']}, 'Loss')

// 藍色代錶增益
Map.addLayer(gainImage.updateMask(gainImage),
            {palette: ['0000FF']}, 'Gain')
            
// 從LSIB數據集加載國家邊界
var countries = ee.FeatureCollection('USDOS/LSIB_SIMPLE/2017')
// 根據代碼找到馬來西亞
var malay = countries.filter(ee.Filter.eq('country_co''MY'))

// 獲取損失圖像
var lossImage = gfc2020.select(['loss'])
var lossAreaImage = lossImage.multiply(ee.Image.pixelArea())

var lossYear = gfc2020.select(['lossyear'])
var lossByYear = lossAreaImage.addBands(lossYear).reduceRegion({
  reducer: ee.Reducer.sum().group({
    groupField1
    }),
  geometry: malay,
  scale30,
  maxPixels1e9
})
print(lossByYear)
var statsFormatted = ee.List(lossByYear.get('groups'))
  .map(function(el{
    var d = ee.Dictionary(el);
    return [ee.Number(d.get('group')).format("20%02d"), d.get('sum')]
  })
var statsDictionary = ee.Dictionary(statsFormatted.flatten())
print(statsDictionary)
var chart = ui.Chart.array.values({
  array: statsDictionary.values(),
  axis0,
  xLabels: statsDictionary.keys()
}).setChartType('ColumnChart')
  .setOptions({
    title'Yearly Forest Loss',
    hAxis: {title'Year'format'####'},
    vAxis: {title'Area (square meters)'},
    legend: { position"none" },
    lineWidth1,
    pointSize3
  })
print(chart)

版权声明:本文为[驚喜疑羞]所创,转载请带上原文链接,感谢。 https://gsmany.com/2021/08/20210815223358053B.html