天天看點

在Google Earth Engine(GEE)中利用人口資料進行分析

今天來分享下如何在GEE中利用人口資料進行分析,在GEE調用的資料為"WorldPop/GP/100m/pop"

分析山西省2001年到2020年人口的增長變化情況

GEE調用代碼如下:

var roi = ee.FeatureCollection('users/lilei655123/shanxi')
Map.centerObject(roi,6)
var clipToCol = function(image){
  return image.clip(roi);
};
// import worldpop data
var worldpop = ee.ImageCollection("WorldPop/GP/100m/pop").filterBounds(roi).map(clipToCol)
                           .filter(ee.Filter.eq('country', 'CHN')).select('population')
print(worldpop)
var start = ee.Date.fromYMD(2020,1,1);
var end = ee.Date.fromYMD(2020,12,31);
var worldpop2020 = ee.Image(worldpop.filterDate(start,end).mean());
worldpop2020 = worldpop2020.clip(roi);
Map.addLayer(worldpop2020,{min:0,max:100,palette: ['24126c', '1fff4f', 'd4ff50']},"population 2020");
var chart =
    ui.Chart.image.seriesByRegion
        ({
          imageCollection:worldpop,
          regions: roi,
          reducer: ee.Reducer.sum(),
          scale: 100,
          xProperty: 'system:time_start'
        })
        .setSeriesNames(['population'])
        .setOptions({
          title: 'population dynamics',
          hAxis: {title: 'Date', titleTextStyle: {italic: false, bold: true}},
          vAxis: {
            title: 'total population',
            titleTextStyle: {italic: false, bold: true}
          },
          lineWidth: 5,
          colors: ['e37d05'],
          curveType: 'function'
        });
print(chart);
//導出影像資料函數
function exportImage(image, region, fileName) {  
   Export.image.toDrive({  
      image: image,  
      description: fileName,  
      fileNamePrefix: fileName, 
      folder: "population",  
      scale: 100, 
      region: roi,  
      maxPixels: 1e13, 
      fileFormat:"GeoTIFF", 
      crs: "EPSG:4326"  
  });  
} 
//擷取每幅影像對應的時間
var indexList = worldpop.reduceColumns(ee.Reducer.toList(), ["system:index"]).get("list");  
print("indexList", indexList);

//循環導出影像,用影像時間對其命名
indexList.evaluate(function(indexs) {  
for (var i=0; i<indexs.length; i++) {  
      var image = worldpop.filter(ee.Filter.eq("system:index", indexs[i])) 
                           .first() 
                           .int16() 
      exportImage(image, roi, "Worldpop-"+indexs[i]); 
  }  
});      

可視化結果:

在Google Earth Engine(GEE)中利用人口資料進行分析

圖中顔色為綠色的區域,表示人口密度越大

統計結果

在Google Earth Engine(GEE)中利用人口資料進行分析

點選“run”,即可批量下載下傳

在Google Earth Engine(GEE)中利用人口資料進行分析

**更多内容請關注微信公衆号“生态遙感監測筆記”