# Geo-Tagging | # Visualization | # Tableau

Vizualization is hosted @ https://arun-thomas.xyz/vizthermalin/


This project was an attempt to study Data visualization using Tableau. Serendeptiously, I came across a visualization of thermal power in the whole world developed by Carbon Brief (https://www.carbonbrief.org/mapped-worlds-coal-power-plants). Carbon Brief sourced their data from www.globalenergymonitor.com and it had a plethora of information regarding thermal power plants. The data of the Indian power plants had some very interesting attributes like parent company, installed capacity, cancelled projects, retired projects, start year etc. However, my plan of plotting the thermal plants hit a road block when I found that geo-location (latitude and longitude) was not available.
Further perusal and experimentation with geo-tagging literature available on the internet yielded the following method of finding latitude and logitudes of 662 numbers of power stations.

Geo Tagging Using Google Geo Code API

import pandas as pd
sheet = 'Sheet1'
# Name of excel file sourced from www.globalenergymonitor.org
file_name = 'CPI.xlsx' 

# Conversion to Dataframe
dfs = pd.read_excel(file_name, sheet_name=sheet)
# Remove Duplicates and convert to list.
plantlist = dfs[dfs.columns[1]].drop_duplicates(keep='first', inplace=False).values.tolist()
# Number of Power Stations
len(plantlist)
662
# Sanity Check - First 11 plants
testList = namelist[0:10]
testList
['Zawar Mines power station',
 'Yermarus power station',
 'Yadadri power station',
 'West Khasi power station',
 'West Godavari Super Thermal Power Station',
 'Welspun Mega Industrial & Energy Park',
 'Welspun Maxsteel power station',
 'Welspun Ghazipur project',
 'Welspun Energy Parbahal Thermal Power Plant',
 'Welspun Energy Mirzapur power station']
# Importing the requests library 
import requests 
  
# Api-endpoint 
URL = "https://maps.googleapis.com/maps/api/geocode/json"

# Output json location with station name.
jso = pd.DataFrame(columns = ['location','json'])

# key = # Get key from Google Cloud 
for location in plantlist:
  
  # Defining a params dict for the parameters to be sent to the API 
  PARAMS = {'address':location,'key':key} 
  
  # Sending get request and saving the response as response object 
  r = requests.get(url = URL, params = PARAMS) 
  
  # Extracting data in json format 
  data = r.json() 
  
  # Appending Location to json output
  jso = jso.append(pd.Series([location,data], index=jso.columns), ignore_index=True)
# Output station name with location in Json.
jso
location json
0 Zawar Mines power station {'results': [{'address_components': [{'long_na...
1 Yermarus power station {'results': [{'address_components': [{'long_na...
2 Yadadri power station {'results': [{'address_components': [{'long_na...
3 West Khasi power station {'results': [{'address_components': [{'long_na...
4 West Godavari Super Thermal Power Station {'results': [{'address_components': [{'long_na...
5 Welspun Mega Industrial & Energy Park {'results': [{'address_components': [{'long_na...
6 Welspun Maxsteel power station {'results': [], 'status': 'ZERO_RESULTS'}
7 Welspun Ghazipur project {'results': [{'address_components': [{'long_na...
8 Welspun Energy Parbahal Thermal Power Plant {'results': [{'address_components': [{'long_na...
9 Welspun Energy Mirzapur power station {'results': [{'address_components': [{'long_na...
10 Welspun Energy Anuppur Thermal Power Plant {'results': [{'address_components': [{'long_na...
11 Welspun Amla power station {'results': [], 'status': 'ZERO_RESULTS'}
12 Wardha Works power station {'results': [{'address_components': [{'long_na...
13 Wardha Warora Power Plant {'results': [{'address_components': [{'long_na...
14 Waral power station {'results': [{'address_components': [{'long_na...
15 Wanakbori Thermal Power Station {'results': [{'address_components': [{'long_na...
16 VS Lignite Plant {'results': [{'address_components': [{'long_na...
17 Vizag Thermal Power Plant {'results': [{'address_components': [{'long_na...
18 Vizag Steel Plant power station {'results': [{'address_components': [{'long_na...
19 Vizag Simhadri power station {'results': [{'address_components': [{'long_na...
20 Vizag Kaizen power station {'results': [{'address_components': [{'long_na...
21 Visakhapatnam Sarda power station {'results': [{'address_components': [{'long_na...
22 Visa Power Jharkhand project {'results': [{'address_components': [{'long_na...
23 Vindhyachal power station {'results': [{'address_components': [{'long_na...
24 Vilayat Caustic power station {'results': [{'address_components': [{'long_na...
25 Vikas Power thermal plant {'results': [], 'status': 'ZERO_RESULTS'}
26 Vijaynagar (KPCL) power station {'results': [], 'status': 'ZERO_RESULTS'}
27 Vijayawada Thermal Power Station (IGCC) {'results': [{'address_components': [{'long_na...
28 Vidarbha Thermal Power {'results': [{'address_components': [{'long_na...
29 Vemavaram power station {'results': [{'address_components': [{'long_na...
... ... ...
632 Athiyakurichi power station {'results': [], 'status': 'ZERO_RESULTS'}
633 Athena Chhattisgarh power station {'results': [{'address_components': [{'long_na...
634 ASTARC power station {'results': [], 'status': 'ZERO_RESULTS'}
635 Asansol power station {'results': [{'address_components': [{'long_na...
636 Asansol Crescent power station {'results': [{'address_components': [{'long_na...
637 ARS Metals Gummidipoondi captive power station {'results': [{'address_components': [{'long_na...
638 Arasmeta Cement Plant power station {'results': [{'address_components': [{'long_na...
639 Anuppur Thermal Power Project {'results': [], 'status': 'ZERO_RESULTS'}
640 Anuppur power station (Newzone) {'results': [{'address_components': [{'long_na...
641 Anpara-E power station {'results': [{'address_components': [{'long_na...
642 Anpara-D power station {'results': [{'address_components': [{'long_na...
643 Anpara-C power station {'results': [{'address_components': [{'long_na...
644 Anpara power station {'results': [{'address_components': [{'long_na...
645 Ankulapatur power station {'results': [{'address_components': [{'long_na...
646 Angul Steel power station {'results': [{'address_components': [{'long_na...
647 Angul Smelter power station {'results': [{'address_components': [{'long_na...
648 Angul power station {'results': [{'address_components': [{'long_na...
649 Amreli power station {'results': [{'address_components': [{'long_na...
650 Amravati Thermal Power Project {'results': [{'address_components': [{'long_na...
651 Amoda power station {'results': [], 'status': 'ZERO_RESULTS'}
652 Ambujanagar Cement Plant power station {'results': [{'address_components': [{'long_na...
653 Amauli Fatehpur power station {'results': [{'address_components': [{'long_na...
654 Akrimota Power Project {'results': [{'address_components': [{'long_na...
655 Ajmer power station {'results': [{'address_components': [{'long_na...
656 Adra Purulia power station {'results': [{'address_components': [{'long_na...
657 Adityapur Works power station {'results': [{'address_components': [{'long_na...
658 Aditya Aluminium power station {'results': [{'address_components': [{'long_na...
659 Adilibad power station (Shalivahana Power Corp.) {'results': [{'address_components': [{'long_na...
660 Adani Korba West power station {'results': [], 'status': 'ZERO_RESULTS'}
661 Adani Godda power station {'results': [{'address_components': [{'long_na...

662 rows × 2 columns

Extracting output json to yield location, latitude and longitude.

f = pd.DataFrame(columns = ['location', 'latitude', 'longitude'])
j = jso['json']
i = 0
for location in plantlist:
   # Extracting latitude, longitude and formatted address of the first matching location 
  if len(j[i]['results']) != 0  :
    latitude = j[i]['results'][0]['geometry']['location']['lat'] 
    longitude = j[i]['results'][0]['geometry']['location']['lng']
  else:
    latitude = ''
    longitude = ''

  f = f.append(pd.Series([location,latitude,longitude], index=f.columns), ignore_index=True)
  i = i + 1
# Final dataframe f with location, latitude and longitude
f
location latitude longitude
0 Zawar Mines power station 24.3516 73.7476
1 Yermarus power station 16.2952 77.3563
2 Yadadri power station 16.7018 79.6207
3 West Khasi power station 25.8383 91.7438
4 West Godavari Super Thermal Power Station 16.8616 81.3652
5 Welspun Mega Industrial & Energy Park 34.1546 -84.7879
6 Welspun Maxsteel power station
7 Welspun Ghazipur project 25.5878 83.5783
8 Welspun Energy Parbahal Thermal Power Plant 23.4494 86.325
9 Welspun Energy Mirzapur power station 25.1366 82.5717
10 Welspun Energy Anuppur Thermal Power Plant 23.1137 81.6976
11 Welspun Amla power station
12 Wardha Works power station 20.7458 78.5985
13 Wardha Warora Power Plant 20.2716 78.9815
14 Waral power station 53.311 -2.94093
15 Wanakbori Thermal Power Station 22.8766 73.3588
16 VS Lignite Plant 27.8489 72.8545
17 Vizag Thermal Power Plant 17.5961 83.0875
18 Vizag Steel Plant power station 17.6467 83.166
19 Vizag Simhadri power station 17.5961 83.0875
20 Vizag Kaizen power station 17.5961 83.0875
21 Visakhapatnam Sarda power station 17.5961 83.0875
22 Visa Power Jharkhand project 23.6102 85.2799
23 Vindhyachal power station 24.096 82.6716
24 Vilayat Caustic power station 21.7647 72.8811
25 Vikas Power thermal plant
26 Vijaynagar (KPCL) power station
27 Vijayawada Thermal Power Station (IGCC) 16.6002 80.5369
28 Vidarbha Thermal Power 20.8223 78.4879
29 Vemavaram power station 16.0975 80.0392
... ... ... ...
632 Athiyakurichi power station
633 Athena Chhattisgarh power station 21.9061 83.129
634 ASTARC power station
635 Asansol power station 23.7164 87.0695
636 Asansol Crescent power station 23.7164 87.0695
637 ARS Metals Gummidipoondi captive power station 13.4236 80.0668
638 Arasmeta Cement Plant power station 21.9491 82.3316
639 Anuppur Thermal Power Project
640 Anuppur power station (Newzone) 23.0729 81.7787
641 Anpara-E power station 24.2049 82.7832
642 Anpara-D power station 24.1958 82.8056
643 Anpara-C power station 24.2052 82.7965
644 Anpara power station 24.2052 82.7965
645 Ankulapatur power station 20.4628 76.9384
646 Angul Steel power station 20.855 85.1907
647 Angul Smelter power station 20.855 85.1907
648 Angul power station 20.855 85.1907
649 Amreli power station 21.6062 71.2228
650 Amravati Thermal Power Project 21.0728 77.9025
651 Amoda power station
652 Ambujanagar Cement Plant power station 20.8334 70.6877
653 Amauli Fatehpur power station 26.0958 80.3504
654 Akrimota Power Project 23.7698 68.6454
655 Ajmer power station 26.4074 74.6267
656 Adra Purulia power station 23.4959 86.6892
657 Adityapur Works power station 22.7879 86.1482
658 Aditya Aluminium power station 21.7323 84.0466
659 Adilibad power station (Shalivahana Power Corp.) 19.6641 78.532
660 Adani Korba West power station
661 Adani Godda power station 24.8186 87.2068

662 rows × 3 columns

# Converting to .csv for further exploration and vizualization in Tableau.
f.to_csv('raw.csv')

Visualization using Tableau

Tableau is great because data can be analyzed very quickly with it. Also, visualizations are generated as dashboards and worksheets. Tableau allows one to create dashboards that provide actionable insights.
The filtering is done company wise, with the size of bubble on the map indicating installed capacity. NTPC, India's largest power major is shown in blue. A date filter is also provided which shows the evolution across time.

References

  1. http://engineering.hackerearth.com/2014/08/21/python-requests-module/
  2. https://globalenergymonitor.org/coal/global-coal-plant-tracker/
  3. https://developers.google.com/maps/documentation/geocoding/intro
  4. https://www.carbonbrief.org/mapped-worlds-coal-power-plants