Nightlights from 2000 – 2020

A full time-series made using a cross-sensor calibration

We uploaded the data from the article below. Data was downloaded from here.

Step 1: import the country boundaries and select Cambodia

// import country layers
var countries = ee.FeatureCollection("USDOS/LSIB_SIMPLE/2017");
// select Cambodia
var kh = countries.filter(ee.Filter.eq("country_na", "Cambodia"));
// add cambodia to the map
Map.addLayer(kh.draw("red"),{},"Cambodia");

Step 2: import the nightlight dataset

// data was uploaded from this dataset: https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/YGIVCD
// article for the data can be found here: https://essd.copernicus.org/articles/13/889/2021/
var nightlights = ee.ImageCollection("projects/servir-mekong/nightlight");

Step 3: select the layers of 2 years and add them to the map

// select data for 2000
var nightlight2000 = ee.Image(nightlights.filterDate("2000-01-01","2000-12-31").first());
// select data for 2020
var nightlight2020 = ee.Image(nightlights.filterDate("2020-01-01","2020-12-31").first());

// add layer to map
Map.addLayer(nightlight2000.clip(kh),{palette:['000000','700000','808080','FFFF00','ffffff','ffffff','ffffff'],min:0,max:10},"nightlights 2000");
Map.addLayer(nightlight2020.clip(kh),{palette:['000000','700000','808080','FFFF00','ffffff','ffffff','ffffff'],min:0,max:10},"nightlights 2020");

Step 4: add the code below to analyse the timeseries

// Define the chart and print it to the console.
var chart =
    ui.Chart.image
        .series({
          imageCollection: nightlights,
          region: kh,
          reducer: ee.Reducer.mean(),
          scale: 300,
          xProperty: 'system:time_start'
        })
        .setSeriesNames(['night light'])
        .setOptions({
          title: 'Date',
          hAxis: {title: 'Date', titleTextStyle: {italic: false, bold: true}},
          vAxis: {
            title: 'nightlight mean',
            titleTextStyle: {italic: false, bold: true}
          },
          lineWidth: 5,
          colors: ['e37d05'],
          curveType: 'function'
        });
           
print(chart);

Step 5: analyse the nightlight per province

// import administrative layers
var provinces = ee.FeatureCollection("projects/servir-mekong/admin/KHM_adm1");
// Define the chart and print it to the console.
var chart =
    ui.Chart.image.byRegion
        ({
          image:nightlight2020,
          regions: provinces,
          reducer: ee.Reducer.mean(),
          scale: 500,
          xProperty: 'NAME_1'
           
        })
        .setSeriesNames(['nighlight'])
        .setOptions({
          title: 'Nightlight per province',
          hAxis: {title: 'Province', titleTextStyle: {italic: false, bold: true}},
          vAxis: {
            title: 'Nightlight',
            titleTextStyle: {italic: false, bold: true}
          }
        }).setChartType('ColumnChart');;
          
print(chart)

Step 6: apply the same for districts

// import administrative layers
var districts = ee.FeatureCollection("projects/servir-mekong/admin/KHM_adm2");
Map.addLayer(districts)
// Define the chart and print it to the console.
var chart =
    ui.Chart.image.byRegion
        ({
          image:nightlight2020,
          regions: districts,
          reducer: ee.Reducer.mean(),
          scale: 500,
          xProperty: 'NAME_2'
           
        })
        .setSeriesNames(['nighlight'])
        .setOptions({
          title: 'Nightlight per district',
          hAxis: {title: 'district', titleTextStyle: {italic: false, bold: true}},
          vAxis: {
            title: 'Nightlight',
            titleTextStyle: {italic: false, bold: true}
          }
        }).setChartType('ColumnChart');;
          
print(chart)

Leave a Reply