Tutorial
This tutorial shows how to:
- Download monthly nighttime light data
- Load the data cubes of radiance and the number of cloud-free observations.
- Clean the data
- Generate zonal statistics
1. Downloading the data
- Create a folder called
radiance
and a folder calledcfobs
. We will use these folders to the radiance and the cloud-free observations images respectively. - Go to the VIIRS Nighttime Lights download page at Earth Observation Group
- Click on
2017
, the on201704
. This means April 2017. - Click on
vcmcfg
(we will use this version of the dataset) - Click on
SVDNB_npp_20170401-20170430_75N060E_vcmcfg_v10_c201705011300.tgz
. Note that the filename has 75N060E in it. This means TILE3, where Mumbai is. - Extract the tar files. Put
SVDNB_npp_20170401-20170430_75N060E_vcmcfg_v10_c201705011300.avg_rade9h.tif
in theradiance
folder. PutSVDNB_npp_20170401-20170430_75N060E_vcmcfg_v10_c201705011300.cf_cvg.tif
in thecfobs
folder. - Repeat the process for all the months. If you are interested only in a certain set of months. Download only those.
2. Loading the data
Create data cubes for radiance and cloud-free observations.
using NighttimeLights
using Rasters
using Dates
dates = collect(Date(2012,4):Month(1):Date(2022, 06))
timestamps = NighttimeLights.yearmon.(dates)
filelist = readdir("~/Downloads/radiance")
radiances = [Raster(i, lazy = true) for i in filelist]
timestamps = collect(1:length(radiances))
series = RasterSeries(radiances, Ti(timestamps))
radiance_datacube = Rasters.combine(series, Ti)
filelist = readdir("~/Downloads/cfobs")
radiances = [Raster(i, lazy = true) for i in filelist]
timestamps = collect(1:length(radiances))
series = RasterSeries(radiances, Ti(timestamps))
ncfobs_datacube = Rasters.combine(series, Ti)
If you haven't downloaded the data, and you want to run the remaining code, you can use load_example()
to load the datacubes of radiance and the number of cloud-free observations around Mumbai
3. Cleaning Data
A single function, clean_complete
, can be used on radiance_datacube
and ncfobs_datacube
to generate a cleaned datacube of radiance.
cleaned_datacube = clean_complete(radiance_datacube, ncfobs_datacube)