0

Can anyone help me how to open little endian and big endian binary files in r. or any code in r to covert binary files in to geotiff.

library(ggplot2)
library(viridis)
library(viridisLite)
library(digest)
library(raster)
file("D:/dddd/binary/CMORPH+MWCOMB_DAILY-025DEG_20170301", "rb")
ls(zz)
ls()
column.names=readBin(zz, character(), n=10)
column.names
varnames = readBin(zz, character(), n=4)
varnames
datavals = readBin(zz, integer(), size = 4, n = 600, endian = "little")
readvals = datavals[1:200]
writevals = datavals[201:400]
mathvals = datavals[401:600]
rdata = cbind(readvals, writevals, mathvals)
colnames(rdata) = varnames
  • What is the concrete problem you need help with? What are the results that you are getting? What are you expecting? What is the difference? Also we cant replicate your problem. [Here](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610#5963610) is some good information on how to create a MRE. And [here](https://stackoverflow.com/help/how-to-ask) is some general information on how to increase your chances of getting a good answer! – dario Mar 08 '20 at 09:01
  • 1
    There are lots of different types of binary file. Do you have any information about the format - like which program produced it, or how the data is supposed to be arranged within it? – Allan Cameron Mar 08 '20 at 09:07
  • DSET ^precl_mon_v1.0.lnx.%y4.gri0.5m * UNDEF -999.0 * options little_endian template * TITLE Monthly Mean Rainfall and Number of Gauges in 0.5x0.5 boxes * XDEF 720 LINEAR 0.25 0.5 * YDEF 360 LINEAR -89.75 0.5 * ZDEF 1 LEVELS 1 * TDEF 1000 LINEAR Jan1948 1mon * VARS 2 rain 1 00 monthly mean rainfall amount (unit=0.1 mm/day) gnum 1 00 number of gauges in each 0.5 deg lat/lon grid box ENDVARS – Sikandar Ali Mar 10 '20 at 13:42

0 Answers0