grdzip − Pack/unpack 1-, 2-, or 4-byte integer data grids
grdzip [ infile] [ −C|D ] [ −1|2|4 ] [ −Eendian ] [ −Foutfile ] [ −H ] [ −Iin_size ] [ −N ] [ −Q ] [ −S ] [ −V ] [ −Xnx ] [ −Ynx ]
grdzip reads a binary 1-, 2-, or 4-byte signed integer grid (or GMT byte, short int or int grid; see −H) (or stdin) and encodes it using the d2zdxdy differences of the data. These increments are stored in a packed 8/16/24/32-bit format that varies with the size of the increments. grdzip takes advantage of the fact that many data sets are smooth, so the differences from point to point are small and can be stored in much less than 16 or 32 bits. The endianness of the calling computer is recorded at the start of the file so that grdzip can make any required byte swapping during unpacking. The packed data is written to file (or stdout) via the bzip2 i/o library, resulting in superior data compression. For technical details, see grdzip.c.
infile |
binary, integer file in scanline format [we read stdin if no file is given]. |
||
−1 |
Selects 1-byte integer grid (i.e., char). |
||
−2 |
Selects 2-byte integer grid (i.e., short int) [Default]. |
||
−4 |
Selects 4-byte integer grid (i.e., int). |
||
−C |
Selects compression [Default]. |
||
−F |
Specifies output file [Default is stdout]. |
||
−H |
Input file has a GMT header structure [Default assumes no header]. |
||
−S |
Performs a byte-swap on incoming data. This is needed when the endian-ness of the data is different from that of the computer (Ignored if -1 is selected). |
||
−V |
Report progress and final statistics to stderr [Default is silent]. |
||
−X |
Number of data columns, i.e., points along each scanline (not needed if header is present). |
||
−Y |
Number of data rows, i.e., scanlines (not needed if header is present). |
To compress the global topography file etopo5.i2, try
grdzip etopo5.i2 −V −X4321 −X2160 -Fetopo5.gbz
To pack Sandwell and Smith’s 2 min gravity img file really small, try
grdzip grav7.2.img −V −X10800 −X6336 > grav7.2.img.gbz
The combined packing and compression reduces this 131 Mb file to approximately 25% of its size.
infile |
Packed file made by grdzip −C [we read stdin if no file is given]. |
||
−D |
Selects decompression [Default is compression]. |
||
−E |
Select desired endian-ness of the output file. Choose B for big-endian, L for little-endian, O for the the original endian-ness on the originating machine, or H for the host-system’s endian-ness [Default]. Ignored if file is a byte grid. |
||
−F |
Specifies output file [Default is stdout]. |
||
−I |
If stdin is read we need the packed file’s actual input size in order to report on expansion/compression ratio. |
||
−N |
Do NOT write a GMT header structure if it is present in the compressed file [Default will write such headers]. |
||
−Q |
Do not extract data, just report what kind (byte, short, or int) of grid, its size, and whether or not it has a GMT header. |
||
−V |
Report progress and final statistics to stderr [Default is silent]. |
To unpack the packed Sandwell and Smith’s 2 min gravity img used in the example above, and make sure it is written in big-endian format, try
grdzip grav7.2.img.gbz −D −EB -V > grav7.2.img
Wessel, P., 2003, Compression of large data grids for Internet transmission, Computers & Geosciences, 29 (5), 665-671.