Drought data for the West African Sahel

Published: 27 June 2022| Version 1 | DOI: 10.17632/zpt24r6csd.1
Contributors:
Zakari Seybou Abdourahamane,
,

Description

The dataset contains: - A NetCDF file containing the time series of drought indices and drought classes based on a composite drought index with a spatial resolution of 1 km2; - A shape file of the African continent used as base map;

Files

Steps to reproduce

Python codes to extract drought data for a given location using geographic coordinates # 1. Load required libraries import pandas as pd import numpy as np import netCDF4 import xarray as xr import matplotlib.pyplot as plt %matplotlib inline import geopandas as gpd # 2. Read the data cdi = xr.open_dataset('NetCDF file location') cdi # Display data information # 3. Extract the drought indices times series for a given location using geographic coordinates # eg. For a location with latitude = 14 and Longitude = 1 # 3.1 Extract the point drought data pt_drought = cdi.sel(lat = 14, lon = 1, method = 'nearest') pt_drought # Display the CDI for the location # 3.2 Convert the point cdi from xarray to dataframe df_pt_drought = pt_drought.to_dataframe() df_pt_drought # Display the dataframe # 3.3 Save the point drought data into csv file df_pt_drought.to_csv("file location/filename.csv") # 4. Extract drought information for a given area using its bounding box # 4.1 Extract data for and area with minimum latitude = 12, maximum latitude = 14, minimum longitude = 0, maximum longitude = 4 areal_drought = cdi.sel(lat = slice(14, 12), lon = slice(0, 4)) areal_drought # Display data information # 4.2 Exemple of plotting CDI time series of the defined area for year 2000 areal_drought.CDI.sel(year = 2000).plot() # 5. Extraction of drought data and drought map for the whole Sahel region for a given year (eg. of 2017) # 5.1 Read the base map (Africa continent shapefile) africa = gpd.read_file(shapefile directory) africa.plot(color = 'none', edgecolor = 'k') # 5.2 Extract the CDI of 2017 cdi_2017 = cdi.sel(year = 2017) # 5.3 Plot the 2017 CDI time series data fig, ax = plt.subplots(1,1, figsize = (16, 8), sharex = True, sharey = True, constrained_layout=False) cmap = plt.get_cmap('viridis_r') cdi_2017_plot = cdi_2017.CDI.plot(ax = ax, cmap = cmap) # plot the Africa map africa.plot(ax = ax, color = 'none', edgecolor = 'k', lw = 0.5) # Display the country names on the map for x, y, label in zip(africa.geometry.centroid.x, africa.geometry.centroid.y, africa.NAME_0): ax.annotate(label, xy=(x, y), xytext=(3, 3), textcoords="offset points") # Set axis labels ax.set_xlabel('', fontsize = 11, y =0.1) ax.set_ylabel('Lat (degree)', fontsize = 14, x =0.1) # Set title ax.set_title('CDI of 2017', {'fontsize' : 14, 'fontweight': 'bold'}) # Set axis limits plt.xlim([-20, 25]) plt.ylim([5, 25]) # Set axis tick label ax.xaxis.set_ticks(np.arange(-20, 30, 5)) ax.yaxis.set_ticks(np.arange(5, 30, 5)) plt.tight_layout() # Save the map as an image plt.savefig("CDI_2017.png", dpi=300, bbox_inches='tight') plt.show()

Institutions

AGRHYMET Regional Centre

Categories

Drought

Licence