Ayanlowo Babatunde
6 min readJan 21, 2022

--

Estimating the Energy potential of any country using GEE, geemap, python geopandas, Folium (NEW)

  1. Introduction

The energy transition refers to the global energy sector's shift from fossil-based energy sources into renewable and clean energy sources (solar, wind, and water). This massive shift aims to move away from reliance on fuels that are destructive to the climate, the environment, and people's well-being. The goal established by the U.N. is to "ensure access to affordable, reliable, sustainable, and modern energy for all" by 2030. However, a successful energy transition for the good of all humanity depends on the actions of individuals.

2. PROJECT SCENARIO

The task estimates the energy potentials in LGAs in Nigeria using the PVOUTS datasets of Data from (https://globalsolaratlas.info/global-pv-potential-study) sites. The Global Photovoltaic Power Potential is a world bank project published to provide an aggregated and harmonized view of solar resources and the potential for developing utility-scale photovoltaic (P.V.) power plants from the perspective of countries and regions. Using consistent, high-resolution, and trusted data and replicable methodology, these write-ups present:

  • Comparison and ranking of Nigeria's local government areas according to their P.V. power potential.

These GIS analyses would help policymakers, project developers, the financial and academic sectors, and professionals and individuals interested in solar energy.

3. THE DATASETS USED FOR ESTIMATING ENERGY POTENTIAL IN NIGERIA

There are two datasets needed for the analysis of energy potential in Nigeria.

A) The PVOUT Raster file represents the daily average energy potential of Nigeria and

The P.V. power output (PVOUT), defined as the specific energy potential yield, is used to illustrate the energy potential in Nigeria. PVOUT represents the amount of power generated per unit of the installed P.V. capacity over the long term. It is measured in kilowatt-hours per installed kilowatt-peak system capacity (kWh/kWp). P.V. power potential (PVOUT) and other parameters are provided in the form of raster (gridded) data in two formats: GeoTIFF and AAIGRID (Esri ASCII Grid). The provided data layers are geographic spatial references (EPSG: 4326). The LTAym_AvgDailyTotals and LTAym_YearlyMonthlyTotals raster images were downloaded from the download section of the globaalsolaratlas sites.

B) LGA shapefile for Nigeria.

The LGA file was extracted from the FAO GAUL (Global Administrative Unit Layers) of the 2015 Second Level Administrative Unit from the Google Earth Engine Catalog. The Global Administrative Unit Layers (GAUL) compile and disseminate the best available information on administrative units for all countries globally, contributing to the standardization of the spatial dataset representing administrative units. The GAUL always maintains global layers with a unified coding system at first (e.g., departments) and second (e.g., districts). Where data is available, it provides layers on a country-by-country basis, down to third, fourth, and lower levels. For example, the energy potential analysis was done based on the local government areas in Nigeria.

4. CONFIGURATION OF DATASETS ON GOOGLE EARTH ENGINE AS LEGACY ASSETS

The downloaded datasets ( LTAym_AvgDailyTotals) were stored as legacy assets on the Google Earth Engine. Legacy assets are associated with your Earth Engine account before Earth Engine's cloud integration with any other resource. This will ensure that we will efficiently use GEE tools for analysis.

HOW TO CREATE A LEGACY DATASET ON GEE

i) Download the PVOUT Geotiff Raster datasets from the globalsolaatlas and store them in your local folder named "Ayanlola."

ii) Go to the Google Earth Engine Cloud Environment and sign in as shown. To use the Google Earth engine, you will need to register to use the Google Earth Engine here.https://developers.google.com/earth-engine/guides/getstarted.

iii) On the top left of the GEE interface, select the Assets tab. The drop-down menu lists. Click on "folder" to create a folder. Name the folder in the dialog box. As shown in fig. 1,

iv) In the Image Upload section, click on the Geotiff (.tif,.tiff) TFRecord and navigate to your local folder to add the PVOUT raster image as a legacy asset.

EXPLORING DATASETS WITH PYTHON

The following steps were taken to explore the datasets in a Python IDE:

  • First, install libraries like the geemap and ee packages to help us analyze the PVOUT legacy assets just created on the Python IDE of choice, i.e., Google Colab.
    N.B. Creating the legacy assets was necessary to use both the geemap and ee packages in the Python IDE.
try:
import geemap, ee
except ModuleNotFoundError:
if 'google.colab' in str(get_ipython()):
print("package not found, installing w/ pip in Google Colab...") ## for google collab
!pip install geemap
else:
print("package not found, installing w/ conda...")
!conda install mamba -c conda-forge -y ## for your local directory
!mamba install geemap -c conda-forge -y
import geemap, ee
  • Initialize and authenticate the Google Earth Engine API.
try:
ee.Initialize() ## This is done anytime you want to use the google earth engine API.
except Exception as e:
ee.Authenticate() ## To help google earth engine link your account
ee.Initialize()
  • Import the necessary libraries as shown in the code below.
import pandas as pd
import ee
import geemap

#import geopandas as gpd
#import rasterio
#import gdal
  • To access the LGA shapefile, downloaded from the FAO GAUL sites. The Shapefile legacy assets path was copied from the Google Earth Engine into the FeatureCollection () of Google Earth Engine API Modules (ee.FeatureCollection) filtered to administrative level 2 and the country of Nigeria. The resulting code is as follows:
# Accessing state level polygon boundaries of Nigeria using FAO dataset
nigeria = ee.FeatureCollection("FAO/GAUL/2015/level2") \
.filter(ee.Filter.eq('ADM0_NAME', 'Nigeria'))
  • To access the solar potential raster image downloaded as an asset, the Raster Assets Path of the PVOUT attached to GEE assets was passed into the IMAGE method of the Google Earth Engine API module (ee. IMAGE()) as follows:
# Access the solar potential raster image downloaded as asset
pvpotential = ee.Image("users/ayanmiayan2010/PVOUT_NIG")
  • Add the reducerRegions () method of the Google Earth Engine modules to output the mean of the PVOUTPUT of the different LGAs in Nigeria. To understand how ReduceRegion Reducer works, read more from the reference section.
# Add reducer output to the Features in the collection.
pvpotential = pvpotential.reduceRegions(
collection = nigeria,
reducer = ee.Reducer.mean(),
);

👋🏻 Enjoyed this article thus far? Kindly click on the FOLLOW button on the top left of this article to follow me for more upcoming articles.

Displaying the Energy potentials with Geopandas Plot

To display the Energy potential results on a Geopandas map. The Gee Features result must be converted to geopandas, then we the energy potentials by state and finally we viewed the energy potential by states on the Nigeria map. The following codes show how to view the energy potential in Nigeria by state.

!pip install -q geopandas
import geopandas as gpd
#Converting the GEE Feature Collection into a pandas dataframe
pvPotentialdf = geemap.ee_to_geopandas(pvpotential)
# Sort the dataframe by PV potential(in this case mean)
statedf=pvPotentialdf[['ADM1_NAME','ADM2_NAME','geometry','mean']]
#statedf.groupby('ADM1_NAME')['mean'].agg('sum')
#plot the map showing the energy potential by states
# high demand areas is in blue


ax=statedf.plot(column='mean',legend=True)
ax.set_title('Energy availability (2018)')
ax.set_axis_off()
Results by sorting Geodataframe by states
Energy Potential on Nigeria Map(High Demand areas in blue)

Adding Interactive Chloropleth MAPS using Folium and Branca module

To add an Interactive map we used folium and Branca modules as follows:

# NOTE: 0.5 doesn't support tooltip, must install dev instead#Installing folium module
!pip install git+https://github.com/python-visualization/folium

#Import Folium and Branca
import branca.colormap as cm
import folium
state_gdf = statedf.set_crs(epsg=4326) #3. Creating interactive choropleth maps with mask.maskFolium
# Estimate centroids of the country
# --------------------
x_map=statedf.centroid.x.mean()
y_map=statedf.centroid.y.mean()
print(x_map,y_map)
#changing properties of the Branca Module
colormap = cm.linear.YlGnBu_09
colormap
colormap = cm.linear.YlGnBu_09.to_step(10)
colormap = cm.linear.YlGnBu_09.to_step(data=statedf['mean'], method='quant', quantiles=[0,0.1,0.75,0.9,0.98,1])
colormap
'''Defining style function and high-light function to set up the Styling of the chloropleth Map'''mymap = folium.Map(location=[y_map, x_map], zoom_start=11,tiles=None)folium.TileLayer('CartoDB positron',name="Light Map",control=False).add_to(mymap)
colormap.caption = "Energy Potential"
style_function = lambda x: {"weight":0.5,
'color':'black',
'fillColor':colormap(x['properties']['mean']),
'fillOpacity':0.75}
highlight_function = lambda x: {'fillColor': '#000000',
'color':'#000000',
'fillOpacity': 0.50,
'weight': 0.1}
t_tip=folium.features.GeoJson(
statedf.set_crs(epsg=4326),
style_function=style_function,
control=False,
highlight_function=highlight_function,
tooltip=folium.features.GeoJsonTooltip(fields=['ADM1_NAME','ADM2_NAME','mean'],
aliases=['STATE','LGA','MEAN ENERGY POTENTIAL/LGA'],
style=("background-color: white; color: #333333; font-family: arial; font-size: 8px; padding: 10px;"),
sticky=True
)
)
#Add the colormap settings tp the folium map objectcolormap.add_to(mymap)
mymap.add_child(t_tip)
mymap
Final Chloropleth Map

Quodos!!! ♚ 💪🏾 💯👏🏼👏🏼 You have come to the End of this Article.
Guess you Enjoy the article? Kindly click on the
FOLLOW button at the left corner of this page for more related and impactful articles by me.

References.

https://developers.google.com/earth-engine/guides/reducers_reduce_region

https://worldbank.github.io/OpenNightLights/tutorials/mod5_3_vector_and_raster_data.html

--

--

Ayanlowo Babatunde

Industrial Engineer with interests in Machine learning/Robotics/IOT