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

One comment

  1. To start with, thank you for creating this blog, very useful for professionals who is into GIS and remote sensing.

    Is it possible if you could share the code in exporting the population density geotiffs (also for the flood maps), as I am having trouble in exporting them.

    Thank you very much, and please continue in doing more tutorials.


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 )

Facebook photo

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

Connecting to %s