[GRASS-user] ERROR: Bytes do not match file size with r.in.bin (but file size is correct!!)

Glynn Clements glynn at gclements.plus.com
Fri May 10 06:39:22 PDT 2013


kapo coulibaly wrote:

> You also want to check how the binary was written in FORTRAN. depending on
> the compiler and/or the access type fortran can write extra bytes before
> and after every record (they are called record marker).

That isn't his problem:

> r.in.bin -f input=inputfile.bin output=outputmap bytes=4
> n=51:05:20.4N s=41:21:50.4N w=5:08:31.2W e=9:33:36E r=19450
> c=29404 anull=-9999.0 --overwrite
...
> WARNING: File Size -2007336096 ... Total Bytes 2287631200
> ERROR: Bytes do not match file size 256

19450 * 29404 * 4 = 2287631200 = 2^32 - 2007336096

So the file is exactly the size it's supposed to be, it's just
overflowing the range of a 32-bit signed integer.

Upgrading is recommended, but in the absence of that, it would be
possible to split the file into two halves with dd, e.g.:

	dd if=inputfile.bin of=file1.bin bs=117616 count=9725
	dd if=inputfile.bin of=file2.bin bs=117616 count=9725 skip=9725

then import them separately and join them with r.patch, e.g.:

	r.in.bin -f input=file1.bin output=map1 bytes=4 \
		n=51:05:20.4N s=46:13:35.4N w=5:08:31.2W e=9:33:36E \
		r=9725 c=29404 anull=-9999.0 --overwrite
	r.in.bin -f input=file2.bin output=map2 bytes=4 \
		n=46:13:35.4N s=41:21:50.4N w=5:08:31.2W e=9:33:36E \
		r=9725 c=29404 anull=-9999.0 --overwrite
	r.patch input=map1,map2 output=outputmap --overwrite
	g.remove rast=map1,map2
	rm file1.bin file2.bin

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-user mailing list