Using nighttime lights for economic inference needs cleaning of the data.

NighttimeLights.na_recodeMethod

The na_recode function also works on datacubes.

radiance = rand(1:10.0, 10, 10, 10)
cloud = rand(0:5, 10, 10, 10)
na_recode(radiance, cloud)

Wherever the number of cloud-free observations is 0, radiance will be marked as missing.

source
NighttimeLights.outlier_varianceMethod

There are extremely high values in the data due to fires, gas flare etc. You may find some values even greater than the aggregate radiance of large cities. Such pixels also have high standard deviation. These pixels may not be of importantance from the point of view of measureming prosperity. The outlier_variance function generates a mask of pixels with standard deviation less that the 99.9th percentile. Essentially, this function can be used to removed top 1 percent of pixels by standard deviation. A mask can be provided to the function, so that it calculates the percentile based on the lit pixel of the mask. For example, if the datacube is a box around India and the mask is the polygon mask of India, the outlier_variance function will calculate the 99th percentile of the standard deviation of the pixels inside India's boundary.

outlier_variance(datacube, mask)
source
NighttimeLights.outlier_hampelFunction

The time series of a pixel may show a few outliers, but as a whole the pixel may be of importantance in measuring economic activity. The outlier_hampel function uses replaces the outlier observations with interpolated values. This is done using the tsclean function the forecast package of R.

sample_timeseries = datacube[1, 2, :] # The time series of pixel [1, 2]
outlier_hampel(sample_timeseries)
source
NighttimeLights.bgnoise_PSTT2021Function

Pixels with no economic activity may show some light due to background noise. These pixels could be in forests, oceans, deserts etc. The bgnoise_PSTT2021 function generates a background moise mask such that those pixels which are considered dark are marked as 0 and those considered lit are marked as 1. The function uses the datacubes of radiance and clouds to generate annual image of the last year the data. The function considers all the pixels below a provided threshold as dark and remaining to be lit.

bgnoise_PSTT2021(radiance_datacube, clouds_datacube)
source
NighttimeLights.bias_PSTT2021Function

The bias correction function can use the datacubes of radiance and the number of cloud-free observations to correct for attenuation in radiance due to low number of cloud-free observations.

bias_PSTT2021(radiance, clouds)
source
NighttimeLights.bias_PSTT2021Method

The bias correction function can use the datacubes of radiance and the number of cloud-free observations to correct for attenuation in radiance due to low number of cloud-free observations.

bias_PSTT2021(radiance, clouds)
source
NighttimeLights.PSTT2021_conventionalMethod

All steps of data cleaning that most researchers do can be performed using the conventional cleaning funciton.

Example

radiance_datacube = rand(1:1000, 10, 10, 10)
clouds_datacube = rand(1:1000, 10, 10, 10)
PSTT2021_conventional(radiance_datacube, clouds_datacube)
source
NighttimeLights.clean_completeMethod

The function clean_complete() represents our views on an optimal set of steps for pre- processing in the future (for the period for which this package is actively maintained). As of today, it is identical to PSTT2021()`

source