Estimate future / historic population density

apply linear regression on the worldPop data.

code below and here.

var worldPop = ee.ImageCollection("WorldPop/POP")

// function to add time as a band
var addTime = function(image) {
  // Scale milliseconds by a large constant to avoid very small slopes
  // in the linear regression output.
  return image.addBands(image.metadata('system:time_start').divide(1e18));

// select country and add time bands
var wp =  worldPop
  .filter(ee.Filter.inList('country', ['VNM']))
  .filter(ee.Filter.equals('UNadj', 'yes')).map(addTime)
  .select(['system:time_start', 'population']);

var display = {
  title: "worldpop data",
  fontSize: 12,
  hAxis: {title: 'Year'},
  vAxis: {title: "population density"}};

// plot a chart
                             scale:100}).setOptions(display));<span id="mce_SELREST_start" style="overflow:hidden;line-height:0;">&#65279;</span>

// apply the linear fit on the data
var wp =  worldPop
  .filter(ee.Filter.inList('country', ['VNM']))
  .filter(ee.Filter.equals('UNadj', 'yes')).map(addTime)
  .select(['system:time_start', 'population'])

// create a list with years
var years = ee.List.sequence(1980,2100,1);

// map of the years and calculate a + bx
var collection = ee.ImageCollection({
  var t = ee.Date.fromYMD(y,1,1).millis();
  var img ="offset").add("scale").multiply(t.divide(1e18)));
  return img.set("system:time_start",t);

// plot a chart

// set viz paramater
var viz = {min:0.0, max:50, palette:"F3FEEE,00ff04,075e09,0000FF,FDFF92,FF2700,FF00E7"};

// estimate 1980 and 2100 population
var img1980 = collection.filterDate(ee.Date.fromYMD(1980,1,1),ee.Date.fromYMD(1980,12,31));
var img2100 = collection.filterDate(ee.Date.fromYMD(2100,1,1),ee.Date.fromYMD(2100,12,31)); 

// add the maps

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s