【GEE合集】欧空局10m土地利用数据已更新至2021,附GEE代码对比两期变化!
1.引言
最近欧空局更新了10m的土地利用数据,本文通过gee来对比两期数据的变化,记录在此,分享给有需要的同学。
2.调用展示
var lc20 = ee.ImageCollection("ESA/WorldCover/v100").first()
var lc21 = ee.ImageCollection("ESA/WorldCover/v200").first()
var leftMap = ui.Map(); //left Map
var rightMap = ui.Map(); //right Map
leftMap.setCenter(111,35,3);
rightMap.setCenter(111,35,3);
leftMap.setControlVisibility(false);
rightMap.setControlVisibility(false);
var linker = new ui.Map.Linker([leftMap,rightMap]); //Link Left Map and Right Map
var splitPanel = ui.SplitPanel({
firstPanel:leftMap,
secondPanel:rightMap,
orientation:'horizontal',
wipe:true
});
ui.root.clear();
ui.root.add(splitPanel);
leftMap.addLayer(lc20);
rightMap.addLayer(lc21);
3.添加图例
添加图例部分参考大神的这篇博客。
// set position of panel
var legend = ui.Panel({
style: {
position: 'bottom-left',
padding: '8px 15px'
}
});
// Create legend title
var legendTitle = ui.Label({
value: 'ESA Landcover',
style: {
fontWeight: 'bold',
fontSize: '18px',
margin: '0 0 4px 0',
padding: '0'
}
});
// Add the title to the panel
legend.add(legendTitle);
// Creates and styles 1 row of the legend.
var makeRow = function(color, name) {
// Create the label that is actually the colored box.
var colorBox = ui.Label({
style: {
backgroundColor: '#' + color,
// Use padding to give the box height and width.
padding: '8px',
margin: '0 0 4px 0'
}
});
// Create the label filled with the description text.
var description = ui.Label({
value: name,
style: {margin: '0 0 4px 6px'}
});
// return the panel
return ui.Panel({
widgets: [colorBox, description],
layout: ui.Panel.Layout.Flow('horizontal')
});
};
// from ESA get palette and names
var palette = ee.List(lc20.get('Map_class_palette')).getInfo()
var names = ee.List(lc20.get('Map_class_names')).getInfo()
// Add color and and names
for (var i = 0; i <palette.length; i++) {
print(palette[i], names[i])
legend.add(makeRow(palette[i], names[i]));
}
// add legend to map
leftMap.add(legend);
以上就是gee对比欧空局两期土地利用的全部内容了,如果对你有帮助的话,请‘点赞’、‘收藏’,‘关注’,你们的支持是我更新的动力。