A package to predict electrification status of settlements and MV power line predictions using NASA VIIRS nightlight imagery.
Project description
Gridlight
This is a fork from Chris Ardernes Gridfinder repository.
Gridlight is a module to help assess energy access levels of human settlmenents for any area of interest.
Gridlight uses the nighttime lights (NTL) data from the Visible Infrared Imaging Radiometer Suite (VIIRS) instruments aboard the NASA/NOAA Suomi National Polar-orbiting Partnership (Suomi NPP) and NOAA-20 satellites.
The algorithm first predicts a mask representing electricity access for each human settlement. Then a minimum spanning tree is calculated which links the previosuly identified areas, using a many-to-many variant Dijkstra algorithm and using existing road networks as a cost function. Adapted from this work from Facebook.
Input requirements
Gridlight requires the following data sources:
- VIIRS data, monthly and annual composites (more information here). The script uses the API access. For this, you need to create a login. You can set this here.
- Population data. HRSL works well, which can be donwloaded here.
- OSM highway data, most easily available here geofabrik
- Existing grids
Get started
Install with pip
Just type
pip install gridfinder
From Github
Clone the repo:
git clone https://github.com/carderne/gridfinder.git
For the installation of the Rtree dependency the libspatialindex-dev library is necessary.
On Ubuntu and Mac, install it with:
$ sudo apt install libspatialindex-dev
On Mac OS X, you need spatialindex instead:
$ brew install spatialindex
This package uses Poetry for dependency management. You can install it here. You can create a virtual environment (called .venv) and install all required dependencies listed in poetry.lock using the following:
$ poetry shell
$ poetry install
Creating credentials
There are two credentials which are necessary to run Gridlight. Both have to be stored in a file called config_local.json.
-
You have to create a login to access the VIIRS data. You can create the login here. Then add the PW and username into the config_local.json file
-
To store the input and resulting data, the package uses cloud buckets. You have to create a bucket and add the credentials into the config file.
Your config_local.json file should then look like this:
{
"viirs_repo_access": {
"username": "<USER EMAIL>",
"password": "<PW>"
},
"remote_storage_config": {
"key": "<KEY>",
"secret": "<SECRET>",
"bucket": "<BUCKET_NAME>",
"base_path": "<BUCKET_BASE_PATH>",
"provider": "google_storage"
}
}
Running the script
There are three steps
- Download the VIIRS data which covers your area of interest.
First we have to download the nightlight data. This is done using the run_download_viirs_imagery.py script.
python run_download_viirs_imagery.py --start-date 2021-01-01 --end-date 2021-12-31
--tiles "75N060W" --tiles "00N060W"
To get a description of all arguments, you can type python run_download_viirs_imagery.py --help
This script downloads the relevant VIIRS data into the data/raw/nightlight_imagery directory and pushes it to the cloud storage bucket
For the start and end dates, the days don´t matter. The month you specify will be fully downloaded independent on the day specified.
There are a total of six tiles: They either go from the equator north or south (see images below and link here):
- 00N 060E (Asia and Australia, south of the equator)
- 00N 060W (Africa south of the equator)
- 00N 180W (South America)
- 75N 060E (Most of Asia, north of the equator)
- 75N 060W (Africa north of the equator, including Europe)
- 75N 180W (North America)
You have to give all the tiles which your area of interest covers. For example, if you want to run Gridlight for South Africa, you need the 00N060W tile. If you are interested in Ethiopia, you need both tiles 00N060W and 75N060W. If more than one tile is given as input, the script will fuse them together. So it´s important that you run the download script with all the tiles you need as argument.
Important: Depending on the start and end dates, the download can take several hours.
- Add other necessary datasets
The script requires a population as well as a road dataset. Both have to be stored into the data/ground_truth directory.
-
An area of interest file: This has to be a vector file outlining the area of interest you want to run Gridlight for.
-
For population, any raster file can be used. The population file is only used to filter out areas which are not populated. The actual population value any of those datasets would have are not taken into consideration. Importantly, a pixel value of 0 refers to 0 population. We recommend using HRSL data, which can be downloaded here or from humdata.org (e.g. here for Sierra Leone.
-
OSM Road data: For the grid prediction, road data can be used to guide the MV power line prediciton. The OSM Highway data can be downloaded here for different countries: Geofabrik
-
If you already have a power grid file, you can specify it. It will be appended to the resulting estimate.
- Run Gridlight
Now you can run the Gridlight script, referencing the datasets above.
To see all input arguments and a description, type:
python run_gridfinder.py --help
For example, a function call might look like this:
python run_gridfinder.py --area-of-interest-data nigeria/nigeria-kano.geojson --roads-data nigeria/nigeria-roads-200101.gpkg --population-data nigeria/population_nga_2018-10-01.tif --grid-truth-data nigeria/nigeriafinal.geojson --nightlight-data nightlight_imagery/75N060W --nightlight-output nigeria/ntl_clipped
Example output
The script provides a set of outputs. TBD
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vida_gridlight-0.1.0.tar.gz.
File metadata
- Download URL: vida_gridlight-0.1.0.tar.gz
- Upload date:
- Size: 21.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.11.0 Linux/5.15.0-1037-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
748fe53fdfa29cde1626e190d0977aaab442e76712a73f83a797e1a5c7b7a140
|
|
| MD5 |
76a793304339861baddf714021b54cd6
|
|
| BLAKE2b-256 |
2dbf60484e0c3bf2d37ee24d24eea91953c2f2756ce623616a8d6dd9adc870ba
|
File details
Details for the file vida_gridlight-0.1.0-py3-none-any.whl.
File metadata
- Download URL: vida_gridlight-0.1.0-py3-none-any.whl
- Upload date:
- Size: 22.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.11.0 Linux/5.15.0-1037-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8779bc8713aadf421020e14f6ad8bc1590f135c1b6f1c35fad442a344409af0a
|
|
| MD5 |
55cfe44c9ce8a8070b0d41461529b9f1
|
|
| BLAKE2b-256 |
063782336b3e139db98468b402a10754a635bebde7996e261d1c3e97de6f4661
|