GRASS GIS 8 Programmer's Manual
8.2.2dev(2023)-3d2c704037
|
#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"
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) |
int Rast__check_format | ( | int | fd | ) |
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, R__::fileinfo, G_calloc, Rast__read_row_ptrs(), fileinfo::row_ptr, and Cell_head::rows.
int Rast__read_null_row_ptrs | ( | int | fd, |
int | null_fd | ||
) |
Definition at line 170 of file raster/format.c.
References fileinfo::cellhd, R__::fileinfo, and Cell_head::rows.
int Rast__read_row_ptrs | ( | int | fd | ) |
Definition at line 155 of file raster/format.c.
References fileinfo::cellhd, Cell_head::compressed, R__::fileinfo, and Cell_head::rows.
Referenced by Rast__check_format().
int Rast__write_null_row_ptrs | ( | int | fd, |
int | null_fd | ||
) |
Definition at line 222 of file raster/format.c.
References fileinfo::cellhd, R__::fileinfo, and Cell_head::rows.
Referenced by Rast__close_null().
int Rast__write_row_ptrs | ( | int | fd | ) |
Definition at line 214 of file raster/format.c.
References fileinfo::cellhd, R__::fileinfo, and Cell_head::rows.