Calculate total population

From world pop data

Step 1: import the relevant dataset and select the 2020 worldpop dataset

// define the countries of interest in this list
var countryList = ["Cambodia","Vietnam","Laos","Burma","Thailand"];
// import the country boundaries and filter for the countries of interest
var countries = ee.FeatureCollection('USDOS/LSIB_SIMPLE/2017').filter(ee.Filter.inList("country_na", countryList));

// import worldpop data
var wp = ee.ImageCollection("WorldPop/GP/100m/pop").filterBounds(countries);

// set the start and end dates
var start = ee.Date.fromYMD(2020,1,1);
var end = ee.Date.fromYMD(2020,12,31);

// filter for the period of interest
var wp2020 = ee.Image(wp.filterDate(start,end).mean());
// clip for the area of interest
wp2020 = wp2020.clip(countries);
// add to map
Map.addLayer(wp2020,{min:0,max:100,palette:['white','gray','black']},"population 2020");

Step 2: draw an area of interest

Step 3: rename geometry to aoi

step 4: calculate the population in aoi

var totalPopulation = wp2020.reduceRegion({reducer:ee.Reducer.sum(),scale:100,geometry:aoi})

find the full code here

Leave a Reply