I have 20 binary files with .grd extension for rainfall (0.25 X 0.25 degree) that I downloaded from Indian Meteorological Department website from 2000 to 2020. The data are arranged in 135x129 grid points. The first data in the record is at 6.5N & 66.5E, the second is at 6.5N & 66.75E, and so on. The last data record corresponds to 38.5N & 100.0E. The yearly data file consists of 365/366 records corresponding to non leap/ leap years. I need to convert these files to text files using R. How do I read binary files with extension. grd in r and convert them to .txt and then merge all 20 files to form a single file?
I went through some earlier posts including this but was not able to convert the .grd files to .txt files
It follows these simple steps:
Read your binary file into R using readBin()
Convert it to a character file using paste(as.character(yourfile.bin),collapse = " ")
Export it as a text file using writeLines(yourfile,"yourfile.txt")
Hope this helps!