Nightlights Satellite Data (Free Download) and Tips to Extract Nightlight Intensity

*Note: A previous version of my site, which had about 5000 monthly views was hacked, and I rebuilt this from scratch. Some content you read before may not be available. I may earn commissions on some links at no cost to you. Opinions are my own.

Want to download Nightlights monthly and annual data? You’ve come to the right place.

Below I show you where to download the nightlight data and how to easily extract night light intensity for any area, region, or point coordinates you may want.

Source 1: Earth Observation Group (EOG)

  • FREE
  • Date range: 2012 – Present
  • Monthly & Annual
  • Format: geotiff files

Click Here to Download (2012-Present).

Source 2: National Oceanic and Atmospheric Administration (NOAA)

  • FREE
  • Date range: 1992- 2013
  • Annual
  • Format: geotiff files

Click Here to Download (1992-2013)

Important Note from the source website:

The Earth Observations Group (EOG) at NOAA/NCEI is producing a version 1 pack of average radiance composite graphics using nighttime data from the Visible Infrared Imaging Radiometer Suite (VIIRS) Day/Night Band (DNB).

Before averaging, the DNB information is filtered to exclude data influenced by stray light, lightning, lunar illumination, and cloud-cover. Cloud-cover is determined using the VIIRS Cloud Mask product (VCM).

Temporal averaging is performed on a monthly and annual basis. Monthly composites’ version 1 set has not yet been filtered to display out lights from boats, fires, aurora, and other temporal lights.

However, the composites have layers with added separation, removing temporal lights and background (non-light) values.

The variant 1 products span the globe from 75N latitude into 65S. The goods are made accessible in geotiff format as a pair of 6 tiles and are created in 15 grids. The tiles have been cut in the equator and each span 120 degrees of latitude.

Each tile is really a set of pictures comprising amounts and radiance values of observations that are available.

From the monthly composites, there are many areas of the world where it’s impossible to get good quality data coverage for that month.

For this reason, it is imperative that users of these data use the observations that are cloud-free file.” – Earth Observation Group.

So, when you are there, make sure to download the “cloud-free” files.

How To extract Nightlight Info for Specific Locations/Point Coordinates in R

# Load packages and read one nightlight file
 library(raster) #install and load this package
 library(sf)
 library(haven)
 library(tidyr)
 filepath <- "C:/Documents/data/nightlight-data/night1.tiff"
 data.raster <- raster(filepath) #read your geotiff data. This is just one file, either the yearly or monthly file for just one time period since their data are separate for different time periods
 #loading Cameroon map
 cmr_shape<- getData('GADM', country='cmr', level=3) #importing the shapefile/map of Cameroon at the lowest admin level available. You can specify for any country. Some countries have the lowest level=2 and others level=3. Play around with it!
 plot(cmr_shape) #to visualize the shapefile.
 cmr_sf <- as(cmr_shape, "sf") #convert the spatial object into an sf object
 # Extracting nightlight data for one year or month for municipalities in Cameroon :)
 extract_cmrdata <- raster::extract(data.raster, cmr_shape, fun=mean, df=TRUE) #This will extract/calculate the temperature of each municipality of Cameroon for each month by averaging all grid cells that overlap the municipality. df=TRUE is just to return the result in a dataframe
 # Note: You can add the option method="bilinear" to the options above.. What it does is it will interpolate the values of the four closest grid cells to give you the value of a specific grid.
 # This is most useful if you have some missing data in your raster (sometimes developing countries data are not complete and given the spatial correlation in satellite data (Donaldson and Storeygard, 2016), I think you can fill up missing values of some grid cells by using nearby non-missing grid cells.)
 # The default method is (method= "simple") and this simply extract the value of the grid cell in which the coordinates fall or the area overlaps without any interpolation.
 # Also, you can add the option: weight=TRUE . It calculate an area weighted average instead of a simple average. The weight is assigned to grid cells (if they are fully inside the polygon or cutting it) and used for calculation.
  
 #combine extracted data with data from map: you will have the country name, region name, district name, municipality name and the nightlight info.
 final_data <- cbind(st_drop_geometry(cmr_sf), extract_cmrdata)
 # you may also have point coordinates you want to extract
 coord <- c(df$lon, df$lat) # here I am creating a table with just the coordinates of my villages or households or centroids
 extract_cmrdata_new <- cbind(coord, raster::extract(data.raster, coord, method=simple, df=TRUE)) #extract the value for that specific point coordinate that falls into a specific grid. and attach the coordinates table to the resulting extracted table.
 # FOR MULTIPLE FILES AT ONCE
 # Now this is where it gets interesting: You will MOST LIKELY have multiple raster files downloaded from the EOG or NOAA site.
 # You can use the approach above to each individual file (time-consuming) OR you can "stack" all files together before extracting the info you need (much easier!)
 Here is how it works:
 # Put all the .tif files in a list using list.files command.
 nightlight_files_tif <- list.files("C:/Users/dbere/Documents/DATA/Nightlight Data/", pattern = ".tif$", full.names = TRUE) # It says, within the folder .../Nightlight Data/, put all the files with an extension .tif in a list called nightlight_files_tif
  
 all.nightlight.data<- stack(nightlight_files_tif)  #stack or append all tif files into one big raster data
 all.nightlight.data #run this to see the structure of the stacked file.. what are the time periods?
 # Next I will crop the big raster of the world for just my area of interest. The reason is extracting often using the large world raster is slow (trust me on that, you want to crop)
 # You can use the shape file to crop or you can define a boundary box using the site  http://bboxfinder.com/, draw a rectangle around a country using the rectancgle feature, copy the bbox info and paste here
 cmr.nightlight.data <- crop(all.nightlight.data, cmr_shape) # now we have longitudinal nightlight data for CMR
 # OR
 cmr.nightlight.data <- crop(all.nightlight.data, extent(c(-179.15056,  179.77341, 18.90986, 72.68750 )) # This is just an exple but the bbox or boundary box can be defined around any country, subregion, region, etc and used to crop the large raster.
 # Finally, I will extract the municipality level nightlight intensity for Cameroon.
 raster data for Cameroon only.
extract_cmrdata_final <- cbind(st_drop_geometry(cmr_sf) raster::extract(cmr.nightlight.data, cmr_shape, fun=mean, df=TRUE)) # extracting avg nightlight intensity at lowest admin level by averaging values of all cells that overlap each municipality shape and appending it to country map data.
 # Note that the st_drop_geometry() allows to drop a column in the cmr_sf dataset called "geometry", which is the polygon of each municipality.
 #If you keep that column, your data extension is still "sf" and you won't be able to export it in a .dta format or .csv as the commands (write_csv or write_dta) to export don't know the sf extension.
 # Additionally, you may want to remove special characters from your variable names before exporting. write_dta() does not know the "." in variable names and will not export your data.
 # Method 1
 names(extract_cmrdata_final) <- make.names(names(extract_cmrdata_final))
 # Method 2
 names(extract_cmrdata_final)<- gsub(""[][!#$%()*,.:;<=>@^_`|~.{}]"","", names(extract_cmrdata_final)) # replace any special character by nothing
 names(extract_cmrdata_final)<- gsub("\\web.stable_lights.avg_vis","nighlightintensity", names(extract_cmrdata_final)) # change weird variable names into good looking ones (i.e., nightlightintensity
 # Now export if you want.
 write_csv(extract_cmrdata_final, ""C:/Users/dbere/Documents/DATA/Nightlight Data/Cameroon_clean")
 write_dta(extract_cmrdata_final, ""C:/Users/dbere/Documents/DATA/Nightlight Data/Cameroon_clean")
 # There you go.. Congrats! If you were a complete beginner, you probably learned something! ;)
Paul Glewwe, Petra Todd - Impact Evaluation in International Development : Theory, Methods and Practice
Click on the book above to download it for FREE. A must-read book on impact evaluation and causal inference methods.

 Hope this post helped. If it did, please share the post to help others as well. Helpful things should be shared!

ALSO READ   Pollution Satellite Data (Free Download) and Codes to Extract Local Pollution Data

Berenger Djoumessi

Berenger is a Ph.D. graduate from the University of Minnesota in Applied Economics, where he studied topics at the intersection of environmental, development, and agricultural economics. Contact: djoum003@umn.edu

Recent Posts