整体的代码思路是选择开放的数据集,进行加载,加载的图层分别包括总人口,男人、女人、青少年、5岁以下儿童、产妇以及超过60岁的人的分类,最后加载了全球开放的国家边界数据。
代码:
var HRSL = ee.ImageCollection("projects/sat-io/open-datasets/hrsl/hrslpop"); var HRSL_men = ee.ImageCollection("projects/sat-io/open-datasets/hrsl/hrsl_men"); var HRSL_women = ee.ImageCollection("projects/sat-io/open-datasets/hrsl/hrsl_women"); var HRSL_youth = ee.ImageCollection("projects/sat-io/open-datasets/hrsl/hrsl_youth"); var HRSL_children_under_five = ee.ImageCollection("projects/sat-io/open-datasets/hrsl/hrsl_children_under_five"); var HRSL_women_reproductive_age = ee.ImageCollection("projects/sat-io/open-datasets/hrsl/hrsl_women_reproductive_age"); var HRSL_elderly_over_sixty = ee.ImageCollection("projects/sat-io/open-datasets/hrsl/hrsl_elderly_over_sixty"); var countries = ee.FeatureCollection("USDOS/LSIB_SIMPLE/2017") // 加载基图和调色板的软件包 var palettes = require('users/gena/packages:palettes') var style = require('users/gena/packages:style') print('Total images',HRSL.size()) //创建一个空间马赛克,使图像集合成为一个单一的图像 var image=HRSL.median() //加载地图展示的位置 Map.setCenter(28.9853, 41.0703,10) //添加国家边界(请随意删除)。 Map.addLayer(ee.Image().paint(countries,0,1), {color:'00FF00'}, 'Area of Interest') //设置图层颜色,分别加载个图层 var rgbVis = {palette: palettes.colorbrewer.Reds[9]} Map.addLayer(image,rgbVis,'HRSL') Map.addLayer(HRSL_men.median(),{palette: palettes.colorbrewer.Blues[9]},'HRSL men',false) Map.addLayer(HRSL_women.median(),{palette: palettes.colorbrewer.PuOr[9]},'HRSL women',false) Map.addLayer(HRSL_youth.median(),{palette: palettes.colorbrewer.PuBuGn[9]},'HRSL youth',false) Map.addLayer(HRSL_children_under_five.median(),{palette: palettes.colorbrewer.YlOrRd[9]},'HRSL Children under five',false) Map.addLayer(HRSL_women_reproductive_age.median(),{palette: palettes.colorbrewer.RdYlBu[9]},'HRSL Women of reproductive age',false) Map.addLayer(HRSL_elderly_over_sixty.median(),{palette: palettes.colorbrewer.YlGnBu[9]},'HRSL Elderly over sixty',false) style.SetMapStyleGrey()