GRASS GIS 7 Programmer's Manual  7.5.svn(2018)-r72636
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
raster/format.c File Reference
#include <unistd.h>
#include <stdlib.h>
#include <grass/config.h>
#include <grass/gis.h>
#include <grass/raster.h>
#include <grass/glocale.h>
#include "R.h"
Include dependency graph for raster/format.c:

Go to the source code of this file.

Functions

int Rast__check_format (int fd)
 
int Rast__read_row_ptrs (int fd)
 
int Rast__read_null_row_ptrs (int fd, int null_fd)
 
int Rast__write_row_ptrs (int fd)
 
int Rast__write_null_row_ptrs (int fd, int null_fd)
 

Function Documentation

int Rast__check_format ( int  fd)

GRASS Raster Format

Small example to illustrate the raster format:

A file may contain the following 3x3 floating point matrix:

10.000 20.000 30.000
20.000 40.000 50.000
30.000 50.000 60.000

The header is a single byte, equal to sizeof(off_t) (typically 4 on a 32-bit platform, 8 on a 64-bit platform). Then, NROWS+1 offsets are written as off_t's (i.e. 4 or 8 bytes, depending upon platform) in big-endian (Motorola) byte order.

Thus, above example is actually interpreted as:

4               sizeof(off_t)
0 0 0 17        offset of row 0
0 0 0 36        offset of row 1
0 0 0 55        offset of row 2
0 0 0 74        offset of end of data

See Rast__write_row_ptrs() below for the code which writes this data. However, note that the row offsets are initially zero; they get overwritten later (if you are writing compressed data, you don't know how much space it will require until you've compressed it).

As for the format of the actual row data, see put_fp_data() in src/libes/gis/put_row.c and RFC 1014 (the XDR specification): http://www.faqs.org/rfcs/rfc1014.html

Definition at line 63 of file raster/format.c.

References fileinfo::cellhd, Cell_head::compressed, fileinfo::data_fd, fd, R__::fileinfo, Rast__read_row_ptrs(), fileinfo::row_ptr, and Cell_head::rows.

Referenced by Rast__open_old().

int Rast__read_null_row_ptrs ( int  fd,
int  null_fd 
)
int Rast__write_null_row_ptrs ( int  fd,
int  null_fd 
)
int Rast__write_row_ptrs ( int  fd)