GRASS GIS 8 Programmer's Manual  8.2.2dev(2023)-3d2c704037
raster/get_row.c File Reference

Raster library - Get raster row. More...

#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <errno.h>
#include <grass/config.h>
#include <grass/raster.h>
#include <grass/glocale.h>
#include "R.h"
Include dependency graph for raster/get_row.c:

Go to the source code of this file.

Macros

#define check_null_bit(flags, bit_num)   ((flags)[(bit_num)>>3] & ((unsigned char)0x80>>((bit_num)&7)) ? 1 : 0)
 

Functions

void Rast_get_row_nomask (int fd, void *buf, int row, RASTER_MAP_TYPE data_type)
 Read raster row without masking. More...
 
void Rast_get_c_row_nomask (int fd, CELL *buf, int row)
 Read raster row without masking (CELL type) More...
 
void Rast_get_f_row_nomask (int fd, FCELL *buf, int row)
 Read raster row without masking (FCELL type) More...
 
void Rast_get_d_row_nomask (int fd, DCELL *buf, int row)
 Read raster row without masking (DCELL type) More...
 
void Rast_get_row (int fd, void *buf, int row, RASTER_MAP_TYPE data_type)
 Get raster row. More...
 
void Rast_get_c_row (int fd, CELL *buf, int row)
 Get raster row (CELL type) More...
 
void Rast_get_f_row (int fd, FCELL *buf, int row)
 Get raster row (FCELL type) More...
 
void Rast_get_d_row (int fd, DCELL *buf, int row)
 Get raster row (DCELL type) More...
 
int Rast__read_null_bits (int fd, int row, unsigned char *flags)
 
void Rast_get_null_value_row (int fd, char *flags, int row)
 Read or simulate null value row. More...
 

Detailed Description

Raster library - Get raster row.

(C) 2003-2009 by the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author
Original author CERL

Definition in file raster/get_row.c.

Macro Definition Documentation

◆ check_null_bit

#define check_null_bit (   flags,
  bit_num 
)    ((flags)[(bit_num)>>3] & ((unsigned char)0x80>>((bit_num)&7)) ? 1 : 0)

Definition at line 898 of file raster/get_row.c.

Function Documentation

◆ Rast__read_null_bits()

int Rast__read_null_bits ( int  fd,
int  row,
unsigned char *  flags 
)

Definition at line 865 of file raster/get_row.c.

References fileinfo::cellhd, Cell_head::cols, R__::fileinfo, and fileinfo::null_fd.

◆ Rast_get_c_row()

void Rast_get_c_row ( int  fd,
CELL buf,
int  row 
)

Get raster row (CELL type)

Reads a row of raster data and leaves the NULL values intact. (As opposed to the deprecated function Rast_get_c_row() which converts NULL values to zero.)

NOTE. When the raster map is old and null file doesn't exist, it is assumed that all 0-cells are no-data. When map is floating point, uses quant rules set explicitly by Rast_set_quant_rules() or stored in map's quant file to convert floats to integers.

Parameters
fdfile descriptor for the opened raster map
bufbuffer for the row to be placed into
rowdata row desired
Returns
void

Definition at line 783 of file raster/get_row.c.

References CELL_TYPE, and Rast_get_row().

Referenced by IL_create_bitmask().

◆ Rast_get_c_row_nomask()

void Rast_get_c_row_nomask ( int  fd,
CELL buf,
int  row 
)

Read raster row without masking (CELL type)

Same as Rast_get_c_row() except no masking occurs.

Parameters
fdfile descriptor for the opened raster map
bufbuffer for the row to be placed into
rowdata row desired
Returns
void

Definition at line 682 of file raster/get_row.c.

References CELL_TYPE, and Rast_get_row_nomask().

Referenced by read_band_row().

◆ Rast_get_d_row()

void Rast_get_d_row ( int  fd,
DCELL buf,
int  row 
)

Get raster row (DCELL type)

Same as Rast_get_f_row() except that the array dcell is double.

Parameters
fdfile descriptor for the opened raster map
bufbuffer for the row to be placed into
rowdata row desired
Returns
void

Definition at line 820 of file raster/get_row.c.

References DCELL_TYPE, and Rast_get_row().

◆ Rast_get_d_row_nomask()

void Rast_get_d_row_nomask ( int  fd,
DCELL buf,
int  row 
)

Read raster row without masking (DCELL type)

Same as Rast_get_d_row() except no masking occurs.

Parameters
fdfile descriptor for the opened raster map
bufbuffer for the row to be placed into
rowdata row desired
Returns
void

Definition at line 714 of file raster/get_row.c.

References DCELL_TYPE, and Rast_get_row_nomask().

◆ Rast_get_f_row()

void Rast_get_f_row ( int  fd,
FCELL buf,
int  row 
)

Get raster row (FCELL type)

Read a row from the raster map open on fd into the float array fcell performing type conversions as necessary based on the actual storage type of the map. Masking, resampling into the current region. NULL-values are always embedded in fcell (never converted to a value).

Parameters
fdfile descriptor for the opened raster map
bufbuffer for the row to be placed into
rowdata row desired
Returns
void

Definition at line 803 of file raster/get_row.c.

References FCELL_TYPE, and Rast_get_row().

◆ Rast_get_f_row_nomask()

void Rast_get_f_row_nomask ( int  fd,
FCELL buf,
int  row 
)

Read raster row without masking (FCELL type)

Same as Rast_get_f_row() except no masking occurs.

Parameters
fdfile descriptor for the opened raster map
bufbuffer for the row to be placed into
rowdata row desired
Returns
void

Definition at line 698 of file raster/get_row.c.

References FCELL_TYPE, and Rast_get_row_nomask().

◆ Rast_get_null_value_row()

void Rast_get_null_value_row ( int  fd,
char *  flags,
int  row 
)

Read or simulate null value row.

Read or simulate null value row and set the cells corresponding to null value to 1. The masked out cells are set to null when the mask exists. (the MASK is taken care of by null values (if the null file doesn't exist for this map, then the null row is simulated by assuming that all zeros in raster map are nulls. Also all masked out cells become nulls.

Parameters
fdfile descriptor for the opened map
bufbuffer for the row to be placed into
flags
rowdata row desired
Returns
void

Definition at line 1075 of file raster/get_row.c.

References R__::fileinfo, and fileinfo::reclass_flag.

◆ Rast_get_row()

void Rast_get_row ( int  fd,
void *  buf,
int  row,
RASTER_MAP_TYPE  data_type 
)

Get raster row.

If data_type is

  • CELL_TYPE, calls Rast_get_c_row()
  • FCELL_TYPE, calls Rast_get_f_row()
  • DCELL_TYPE, calls Rast_get_d_row()

    Reads appropriate information into the buffer buf associated with the requested row row. buf is associated with the current window.

    Note, that the type of the data in buf (say X) is independent of the type of the data in the file described by fd (say Y).

    • Step 1: Read appropriate raw map data into a intermediate buffer.
    • Step 2: Convert the data into a CPU readable format, and subsequently resample the data. the data is stored in a second intermediate buffer (the type of the data in this buffer is Y).
    • Step 3: Convert this type Y data into type X data and store it in buffer "buf". Conversion is performed in functions "transfer_to_cell_XY". (For details of the conversion between two particular types check the functions).
    • Step 4: read or simmulate null value row and zero out cells corresponding to null value cells. The masked out cells are set to null when the mask exists. (the MASK is taken care of by null values (if the null file doesn't exist for this map, then the null row is simulated by assuming that all zero are nulls *** in case of Rast_get_row() and assuming that all data is valid in case of G_get_f/d_raster_row(). In case of deprecated function Rast_get_c_row() all nulls are converted to zeros (so there are no embedded nulls at all). Also all masked out cells become zeros.
Parameters
fdfile descriptor for the opened raster map
bufbuffer for the row to be placed into
rowdata row desired
data_typedata type
Returns
void

Definition at line 759 of file raster/get_row.c.

Referenced by Rast_get_c_row(), Rast_get_d_row(), Rast_get_f_row(), and Rast_map_to_img_str().

◆ Rast_get_row_nomask()

void Rast_get_row_nomask ( int  fd,
void *  buf,
int  row,
RASTER_MAP_TYPE  data_type 
)

Read raster row without masking.

This routine reads the specified row from the raster map open on file descriptor fd into the buf buffer like Rast_get_c_row() does. The difference is that masking is suppressed. If the user has a mask set, Rast_get_c_row() will apply the mask but Rast_get_c_row_nomask() will ignore it. This routine prints a diagnostic message and returns -1 if there is an error reading the raster map. Otherwise a nonnegative value is returned.

Note. Ignoring the mask is not generally acceptable. Users expect the mask to be applied. However, in some cases ignoring the mask is justified. For example, the GRASS modules r.describe, which reads the raster map directly to report all data values in a raster map, and r.slope.aspect, which produces slope and aspect from elevation, ignore both the mask and the region. However, the number of GRASS modules which do this should be minimal. See Mask for more information about the mask.

Parameters
fdfile descriptor for the opened raster map
bufbuffer for the row to be placed into
rowdata row desired
data_typedata type
Returns
void

Definition at line 666 of file raster/get_row.c.

Referenced by Rast_get_c_row_nomask(), Rast_get_d_row_nomask(), Rast_get_f_row_nomask(), and Rast_get_vrt_row().