Skip to content

Electrification

Access Data

Have more questions? Contact Vivek Sakhrani


Overview

Atlas AI's Electrification Status layer estimates the availability of access to the electricity grid at a particular location, i.e. the presence or absence of electrification. At any snapshot in time, the Electrification Status is binary - either 'yes' or 'no'.

Methods

For details on methods, input data sources, validation, and background citations, please consult:
https://docs.atlasai.co/infrastructure/electrification/

Version information

This data is available in multiple versions in raster format and is updated annually for several geographic regions.

Version 2022

Data type: Uint8
No-data value: 255
Min/max values: 1 (min), 2 (max)
Time horizon: 04/2012–12/2021
Spatial representation: Raster grid
Spatial resolution: 1km x 1km
Extent: 43 countries in Sub-Saharan Africa (Angola, Burundi, Benin, Burkina Faso, Botswana, Central African Republic, Côte d'Ivoire, Cameroon, Democratic Republic of the Congo, Republic of the Congo, Eritrea, Ethiopia, Gabon, Ghana, Guinea, The Gambia, Guinea-Bissau, Equatorial Guinea, Kenya, Liberia, Lesotho, Madagascar, Mali, Mozambique, Mauritania, Malawi, Namibia, Niger, Nigeria, Rwanda, Senegal, Sierra Leone, Somalia, South Sudan, Sudan, Eswatini, Chad, Togo, Tanzania, Uganda, South Africa, Zambia, Zimbabwe)
National boundaries source: geoBoundaries

Version 2022 (beta)

Data type: Uint8
No-data value: 255
Min/max values: 1 (min), 2 (max)
Time horizon: 04/2012–12/2021
Spatial representation: Raster grid
Spatial resolution: 1km x 1km
Extent: Six countries in South Asia (Bangladesh, Bhutan, India, Nepal, Pakistan, Sri Lanka)
National boundaries source: geoBoundaries and Natural Earth (India POV)

Version 2021

Data type: Uint8
No-data value: 255
Min/max values: 0 (min), 1 (max)
Time horizon: 04/2012–12/2020
Spatial representation: Raster grid
Spatial resolution: 2km x 2km
Extent: Sub-Saharan Africa

Version compatibility

Version 2022 and Version 2022 (beta) have a higher spatial resolution (1km x 1km) than Version 2021 (2km x 2km). Version 2022 and Version 2022 (beta) are therefore incompatible with Version 2021.

Code samples

Below are two code samples for, first, generating color maps to display Electrification data in Python and, second, calculating zonal statistics (proportion of population with access to electrification) for an area of interest in Python.

Generate Electrification color maps

import numpy as np
from matplotlib import colors


def hex2color_map(name, hex_list):
    color_tuples = list(map(_parse_hex, hex_list))
    color_tuples_normalized = [
        (e[0] / 255.0, e[1] / 255.0, e[2] / 255.0, 255.0) for e in color_tuples
    ]
    cmap = normalized_color_tuples2cmap(color_tuples_normalized)
    save_cmap(name, cmap)


def save_cmap(name, cmap):
    cmap_vals = cmap(np.linspace(0, 1, 255))
    cmap_uint8 = (cmap_vals * 255).astype("uint8")

    np.save(name + "_rgba.npy", cmap_uint8)


def normalized_color_tuples2cmap(color_tuples_normalized, interpolate=True):
    if not interpolate:
        # No color interpolation:
        return colors.ListedColormap(color_tuples_normalized, "woooooooooooo")

    ### With color interpolation:
    nc = len(color_tuples_normalized)
    c = np.zeros((3, nc, 3))
    rgb = ["red", "green", "blue"]
    for idx, e in enumerate(color_tuples_normalized):
        for ii in range(3):
            c[ii, idx, :] = [float(idx) / float(nc - 1), e[ii], e[ii]]

    cdict = dict(zip(rgb, c))
    cmap = colors.LinearSegmentedColormap("woooooooooooo", cdict)
    return cmap


def _parse_hex(color_code):
    return (
        int(color_code[1:3], 16),
        int(color_code[3:5], 16),
        int(color_code[5:7], 16),
    )


hex2color_map(
    "AtlasAI_Electrification",
    [
        "#fcfbfd",
        "#efedf5",
        "#dadaeb",
        "#bcbddc",
        "#9e9ac8",
        "#807dba",
        "#6a51a3",
        "#54278f",
        "#3f007d",
    ],
)

Calculate zonal statistics

import rasterio as rio
import geopandas as gpd
from rasterstats import zonal_stats

# convert boundaries file crs to raster crs (epsg:3857) and save as boundaries-3857.gpkg
gdf = gpd.read_file('boundaries.geojson')
gdf.to_crs(3857).to_file('boundaries-3857.gpkg')

# electrification-mask population by multiplying ele and pop pixel values and save as ELE-masked-POP_Country_YYYY.tif
with rio.open('ELE_Country_YYYY.tif') as src:
    ele = src.read(masked=True)
    profile = src.profile

with rio.open('POP_Country_YYYY.tif') as src:
    pop = src.read(masked=True)

ele_masked_pop = ele * pop

with rio.open('ELE-masked-POP_Country_YYYY.tif', 'w', **profile) as dst:
    dst.write(ele_masked_pop)

# calculate zonal statistics (sum) for population and electrification-masked population
ele_masked_pop_sum = zonal_stats("boundaries-3857.gpkg",
                                 "ELE-masked-POP_Country_YYYY.tif",
                                 stats='sum')

pop_sum = zonal_stats("boundaries-3857.gpkg",
                      "POP_Country_YYYY.tif",
                      stats='sum')

# calculate the proportion of the population with access to electrification by dividing the electrification-masked population sum by the population sum
pop_with_ele_prop = ele_masked_pop_sum[0]['sum'] / pop_sum[0]['sum']