GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-d6dec75dd4
raster/raster.c File Reference

Raster Library - Raster cell value routines. More...

#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
#include <grass/raster.h>
Include dependency graph for raster/raster.c:

Go to the source code of this file.

Functions

int Rast_raster_cmp (const void *v1, const void *v2, RASTER_MAP_TYPE data_type)
 Compares raster values. More...
 
void Rast_raster_cpy (void *v1, const void *v2, int n, RASTER_MAP_TYPE data_type)
 Copies raster values. More...
 
void Rast_set_c_value (void *rast, CELL cval, RASTER_MAP_TYPE data_type)
 Places a CELL raster value. More...
 
void Rast_set_f_value (void *rast, FCELL fval, RASTER_MAP_TYPE data_type)
 Places a FCELL raster value. More...
 
void Rast_set_d_value (void *rast, DCELL dval, RASTER_MAP_TYPE data_type)
 Places a DCELL raster value. More...
 
CELL Rast_get_c_value (const void *rast, RASTER_MAP_TYPE data_type)
 Retrieves the value of give type from pointer p. More...
 
FCELL Rast_get_f_value (const void *rast, RASTER_MAP_TYPE data_type)
 Retrieves the value of given raster type from pointer p (FCELL) More...
 
DCELL Rast_get_d_value (const void *rast, RASTER_MAP_TYPE data_type)
 Retrieves the value of given type from pointer p (DCELL) More...
 

Detailed Description

Raster Library - Raster cell value routines.

(C) 2001-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/raster.c.

Function Documentation

◆ Rast_get_c_value()

CELL Rast_get_c_value ( const void *  rast,
RASTER_MAP_TYPE  data_type 
)

Retrieves the value of give type from pointer p.

Retrieves the value of type data_type from pointer p, converts it to CELL type and returns the result. If null value is stored in p, returns CELL null value.

Used for retrieving CELL values from raster cells of any type.

Note: when data_type != CELL_TYPE, no quantization is used, only type conversion.

Parameters
rastpointer to raster cell value
data_typeraster type (CELL, FCELL, DCELL)
Returns
raster value

Definition at line 200 of file raster/raster.c.

◆ Rast_get_d_value()

DCELL Rast_get_d_value ( const void *  rast,
RASTER_MAP_TYPE  data_type 
)

Retrieves the value of given type from pointer p (DCELL)

Retrieves the value of type data_type from pointer p, converts it to DCELL type and returns the result. If null value is stored in p, returns DCELL null value.

Used for retrieving DCELL values from raster cells of any type.

Parameters
rastpointer to raster cell value
data_typeraster type (CELL, FCELL, DCELL)
Returns
raster value

Definition at line 268 of file raster/raster.c.

Referenced by Rast_set_cat().

◆ Rast_get_f_value()

FCELL Rast_get_f_value ( const void *  rast,
RASTER_MAP_TYPE  data_type 
)

Retrieves the value of given raster type from pointer p (FCELL)

Retrieves the value of type data_type from pointer p, converts it to FCELL type and returns the result. If null value is stored in p, returns FCELL null value.

Used for retrieving FCELL values from raster cells of any type.

Parameters
rastpointer to raster cell value
data_typeraster type (CELL, FCELL, DCELL)
Returns
raster value

Definition at line 234 of file raster/raster.c.

References CELL_TYPE, DCELL_TYPE, FCELL_TYPE, Rast_is_null_value(), and Rast_set_f_null_value().

◆ Rast_raster_cmp()

int Rast_raster_cmp ( const void *  v1,
const void *  v2,
RASTER_MAP_TYPE  data_type 
)

Compares raster values.

Parameters
v1,v2values to be compared
data_typeraster type (CELL, FCELL, DCELL)
Returns
1 if p > q or only q is null value
-1 if p < q or only p is null value
0 if p == q or p==q==null value

Definition at line 29 of file raster/raster.c.

References CELL_TYPE, DCELL_TYPE, FCELL_TYPE, and Rast_is_null_value().

◆ Rast_raster_cpy()

void Rast_raster_cpy ( void *  v1,
const void *  v2,
int  n,
RASTER_MAP_TYPE  data_type 
)

Copies raster values.

If v2 is null value, sets v2 to null value. n is typically size of the destination array and the source array is at least that large.

Parameters
v1destination array for raster values
v2source array with raster values
nnumber of values to copy
data_typeraster type (CELL, FCELL, DCELL)

Definition at line 79 of file raster/raster.c.

References Rast_cell_size().

◆ Rast_set_c_value()

void Rast_set_c_value ( void *  rast,
CELL  cval,
RASTER_MAP_TYPE  data_type 
)

Places a CELL raster value.

If Rast_is_c_null_value() is true, sets p to null value. Converts CELL val to data_type (type of p) and stores result in p. Used for assigning CELL values to raster cells of any type.

Parameters
rastpointer to raster cell value
cvalvalue to set
data_typeraster type (CELL, FCELL, DCELL)

Definition at line 95 of file raster/raster.c.

◆ Rast_set_d_value()

void Rast_set_d_value ( void *  rast,
DCELL  dval,
RASTER_MAP_TYPE  data_type 
)

Places a DCELL raster value.

If Rast_is_d_null_value() is true, sets p to null value. Converts DCELL val to data_type (type of p) and stores result in p. Used for assigning DCELL values to raster cells of any type.

Parameters
rastpointer to raster cell value
fvalvalue to set
data_typeraster type (CELL, FCELL, DCELL)

Definition at line 161 of file raster/raster.c.

Referenced by Rast_get_next_marked_cat().

◆ Rast_set_f_value()

void Rast_set_f_value ( void *  rast,
FCELL  fval,
RASTER_MAP_TYPE  data_type 
)

Places a FCELL raster value.

If Rast_is_f_null_value() is true, sets p to null value. Converts FCELL val to data_type (type of p) and stores result in p. Used for assigning FCELL values to raster cells of any type.

Parameters
rastpointer to raster cell value
fvalvalue to set
data_typeraster type (CELL, FCELL, DCELL)

Definition at line 128 of file raster/raster.c.

References CELL_TYPE, DCELL_TYPE, FCELL_TYPE, Rast_is_f_null_value, and Rast_set_null_value().