The World Bank Climate API is a REST API that provides historical and projected climate data by country using the General Circulation Models used by the Intergovernmental Panel on Climate Change - IPCC, 4th Assesment Report found here.
These instructions will get you a copy of the project up and running on your local machine.
Python 3.7
Once the repo has been cloned or downloaded onto the system, open wb_climateapi_reader.py in a text editor or IDE of choice.
The inputs required to obtain data from the API can be modified in the main function:
if __name__ == '__main__':
querry_response = set_querry_url("mavg","tas","2020","2039","LKA","csv")
download_formatted_data(querry_response)
The inputs to the function set_querry_url correspond to the inputs of the GET method used by the REST API to acccess data based on the following pattern.
For example, to obtain the annual average temperature in Celsius, for the forecasted period 2020-2039, for Sri Lanka the script can be modifed as follows:
if __name__ == '__main__':
querry_response = set_querry_url("annualavg","tas","2020","2039","LKA","csv")
download_formatted_data(querry_response)
The script currently supports JSON and CSV. The final term, "csv" (or json) is required and will write the data directly to a csv file (or json file).
On Linux and Mac the script wb_climateapi_reader.py can be run be evoking Python as:
<directory>python wb_climateapi_reader.py
On Windows, Powershell can be used to run the script as follows:
<path of python 3.7>python.exe "<file path>world_bank_climate_reader.py"
- Praveen Jayasuriya - initial work - praveenjayasuriya.com
This project is licensed under the MIT License