Loading...
墨滴

惊喜疑羞

2021/08/15  阅读:33  主题:山吹

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)

惊喜疑羞

2021/08/15  阅读:33  主题:山吹

作者介绍

惊喜疑羞