Sillians
Sillians

Reputation: 199

Downloading Gridded CHIRPS data sets using python

I am working with Satellite Gridded dataset from CHIRPS, Here is the link to the dataset: https://data.chc.ucsb.edu/products/CHIRPS-2.0/ working specifically with the African Daily dataset : https://data.chc.ucsb.edu/products/CHIRPS-2.0/africa_daily/tifs/p25/ , The data spans from 1981 to 2020, The Idea is to download the data using the url and be able to work with it, I have not worked with image or Satellite data before, and would appreciate it if I can get any help on how to approach this. thanks

Upvotes: 0

Views: 1715

Answers (1)

pyaj
pyaj

Reputation: 640

It would be better for you to work with CHIRPS netcdf dataset.

In this solution, I clipped the CHIRPS global dataset using the boundaries (xmin xmax ymin and ymax) of my study area ie Ghana.

#load modules
import numpy as np
import pandas as pd
import xarray as xr
# load chirps global monthly precipitation data
!wget https://data.chc.ucsb.edu/products/CHIRPS-2.0/global_monthly/netcdf/chirps-v2.0.monthly.nc
# load chirps precipitation data
chirps = xr.open_dataset('/content/chirps-v2.0.monthly.nc')
# select precipitation variable
pr = chirps['precip']

# select boundaries (xmin, xmax, ymin and ymax) and time period of interest
pr_ghana = pr.sel(longitude=slice(-3.3,1.2), latitude=slice(4.7,11.2),time=slice('1981','2020'))
# save clipped data
pr_ghana.to_netcdf('/content/chirps-v2.0.monthly_ghana.nc')

The nectcdf file should be easy to manipulate using xarray!

Upvotes: 3

Related Questions