How to read station information of the global historical climate network daily data (ghcnd)

  Data, Pandas, Python

The global historical climate network daily data (ghcnd) is the widely used global climate data for all purposes. However, the data size is huge. If you only want to use data from a certain area, your best bet is to find the site information first, and then download the data for those weather stations directly. The following simple program help you do this easily.

import pandas as pd
#read weather station information
colspecs=[(0,12),(12,20),(20,30),(30,37),(37,40),(40,65),(65,79),(79,-1)]
ghcnd=pd.read_fwf('ghcnd-stations.txt',
                  index_col=False,
                  colspecs=colspecs,
                  names=['ID','Lat','Lon','Elv','flg1','Name','flg2','Num'])
#select station based on latitude and longitude
ghcnd.loc[(ghcnd.Lat>20) & (ghcnd.Lat<45) & (ghcnd.Lon>105) & (ghcnd.Lon<125)]

Global Historical Climatology Network – Daily (GHCN-Daily), Version 3