基于GEE实现物种分布模型之随机森林法
- 1.物种分布数据
- 2.研究区绘制
- 3.预测因子选择
1.物种分布数据
根据研究目的和需要导入物种数据:
// Load presence data
var Data = ee.FeatureCollection("users/************736/Distribution");
print('Original data size:', Data.size());// Define spatial resolution to work with (m)
var GrainSize = 1000;function RemoveDuplicates(data){var randomraster = ee.Image.random().reproject('EPSG:4326', null, GrainSize);var randpointvals = randomraster.sampleRegions({collection:ee.FeatureCollection(data), scale: 15000, geometries: true});return randpointvals.distinct('random');
}var Data_Remove = RemoveDuplicates(Data);
print('Final data size:', Data_Remove.size());
print('Final data size:', Data_Remove);// Add two maps to the screen.
var left = ui.Map();
var right = ui.Map();
ui.root.clear();
ui.root.add(left);
ui.root.add(right);// Link maps, so when you drag one map, the other will be moved in sync.
ui.Map.Linker([left, right], 'change-bounds');// Visualize presence points on the map
right.addLayer(Data_Remove, {color:'red'}, 'RemoveDuplicates-Presence', 1);
left.addLayer(Data, {color:'blue'}, 'Presence', 1);
此处使用两个模块来展示数据图像:
2.研究区绘制
这里要注意,使用USDOS/LSIB_SIMPLE/2017数据时,他给出的中国地图有错误,如没有台湾省,以及新疆和西藏接壤处存在问题。
// Define the AOI
// var AOI = Data.geometry().bounds().buffer({distance:50000, maxError:1000});
var AOI = ee.FeatureCollection('USDOS/LSIB_SIMPLE/2017').filter(ee.Filter.eq('country_co', 'CH'));
// var AOI = ee.FeatureCollection('users/******736/ChinaMap');
var AOI_polygon = AOI.geometry().bounds();// Add border of study area to the map
var outline = ee.Image().byte().paint({featureCollection: AOI, color: 1, width: 3});
right.addLayer(outline, {palette: '0000FF'}, "Final Study Area");
left.addLayer(outline, {palette: 'FF0000'}, "Original Study Area");// Center each map to the area of interest
right.centerObject(AOI, 3); //Number indicates the zoom level
left.centerObject(AOI, 3); //Number indicates the zoom level
3.预测因子选择
常见的因子包括worldclim中的生物气候因子、地形因子、植被因子等,这里使用了以上三者作为分析,当然你还可以添加土壤因子和人为因子等因素进去。
// Load WorldClim BIO Variables (a multiband image) from the data catalog
var BIO = ee.Image("WORLDCLIM/V1/BIO");// Load elevation data from the data catalog
// and calculate slope, aspect, and a simple hillshade from the terrain Digital Elevation Model.
var Terrain = ee.Algorithms.Terrain(ee.Image("USGS/SRTMGL1_003")); // 30m year:2000// Load NDVI 250 m collection and estimate median annual tree cover value per pixel
var MODIS = ee.ImageCollection("MODIS/006/MOD44B");
var MedianPTC = MODIS.filterDate('2000-01-01', '2020-12-31').select(['Percent_Tree_Cover']).median();// Combine bands into a single multi-band image
var predictors = BIO.addBands(Terrain).addBands(MedianPTC);
print("Predictors values:", predictors)var watermask = Terrain.select('elevation').gt(0); //Create a water mask
var predictors = predictors.updateMask(watermask).clip(AOI);// Select subset of bands to keep for habitat suitability modeling
// 'bio04','bio05','bio06','bio12','elevation','Percent_Tree_Cover'
var bands = ['bio04','bio05','bio06','bio12','elevation','Percent_Tree_Cover'];
var predictors = predictors.select(bands);// Display layers on the map
right.addLayer(predictors, {bands:['elevation'], min: 0, max: 8000, palette: ['000000','006600', '009900','33CC00','996600','CC9900','CC9966','FFFFFF',]}, 'Elevation (m)', 0);
right.addLayer(predictors, {bands:['bio05'], min: 100, max: 490, palette:'white,red'}, 'Max temperature of warmest month', 0);
right.addLayer(predictors, {bands:['bio12'], min: 0, max: 4000, palette:'white,blue'}, 'Annual precipitation (mm)', 0);
right.addLayer(predictors, {bands:['Percent_Tree_Cover'], min: 0, max: 70, palette:'white,green, red'}, 'Percent_Tree_Cover', 0);
海拔:
最大温度:
年降水量:
森林植被覆盖率: