GRASS GIS 7 Programmer's Manual  7.7.svn(2018)-r73786
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
null_val.c File Reference

Raster Library - NULL value management. More...

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

Go to the source code of this file.

Functions

void Rast__set_null_value (void *rast, int numVals, int null_is_zero, RASTER_MAP_TYPE data_type)
 To set one or more raster values to null. More...
 
void Rast_set_null_value (void *buf, int numVals, RASTER_MAP_TYPE data_type)
 To set one or more raster values to null. More...
 
void Rast_set_c_null_value (CELL *cellVals, int numVals)
 To set a number of CELL raster values to NULL. More...
 
void Rast_set_f_null_value (FCELL *fcellVals, int numVals)
 To set a number of FCELL raster values to NULL. More...
 
void Rast_set_d_null_value (DCELL *dcellVals, int numVals)
 To set a number of DCELL raster values to NULL. More...
 
int Rast_is_null_value (const void *rast, RASTER_MAP_TYPE data_type)
 To check if a raster value is set to NULL. More...
 
int Rast_is_c_null_value (const CELL *cellVal)
 To check if a CELL raster value is set to NULL. More...
 
int Rast_is_f_null_value (const FCELL *fcellVal)
 To check if a FCELL raster value is set to NULL. More...
 
int Rast_is_d_null_value (const DCELL *dcellVal)
 To check if a DCELL raster value is set to NULL. More...
 
void Rast_insert_null_values (void *rast, char *null_row, int ncols, RASTER_MAP_TYPE data_type)
 To insert null values into a map. More...
 
void Rast_insert_c_null_values (CELL *cellVal, char *null_row, int ncols)
 To insert null values into an integer raster map (CELL) More...
 
void Rast_insert_f_null_values (FCELL *fcellVal, char *null_row, int ncols)
 To insert null values into an floating-point raster map (FCELL) More...
 
void Rast_insert_d_null_values (DCELL *dcellVal, char *null_row, int ncols)
 To insert null values into an floating-point raster map (FCELL) More...
 
int Rast__check_null_bit (const unsigned char *flags, int bit_num, int n)
 Check NULL. More...
 
int G__set_flags_from_01_random (const char *zero_ones, unsigned char *flags, int col, int n, int ncols)
 Given array of 0/1 of length n starting from column. More...
 
void Rast__convert_01_flags (const char *zero_ones, unsigned char *flags, int n)
 ? More...
 
void Rast__convert_flags_01 (char *zero_ones, const unsigned char *flags, int n)
 ? More...
 
void Rast__init_null_bits (unsigned char *flags, int cols)
 ? More...
 

Detailed Description

Raster Library - NULL value management.

To provide functionality to handle NULL values for data types CELL, FCELL, and DCELL. May need more...

(C) 2001-2009 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 unknown - probably CERL
Justin Hickey - Thailand - jhick.nosp@m.ey@h.nosp@m.pcc.n.nosp@m.ecte.nosp@m.c.or..nosp@m.th

Definition in file null_val.c.

Function Documentation

int G__set_flags_from_01_random ( const char *  zero_ones,
unsigned char *  flags,
int  col,
int  n,
int  ncols 
)

Given array of 0/1 of length n starting from column.

Note: Only for internal use.

Given array of 0/1 of length n starting from column set the corresponding bits of flags; total number of bits in flags is ncols.

Parameters
zero_ones
flags
col
n
ncols
Returns
0
1

Definition at line 374 of file null_val.c.

References count, Rast__check_null_bit(), Rast__convert_01_flags(), and Rast__null_bitstream_size().

int Rast__check_null_bit ( const unsigned char *  flags,
int  bit_num,
int  n 
)

Check NULL.

Note: Only for internal use.

Parameters
flagsnull bitmap
bit_numindex of bit to check
nsize of null bitmap (in bits)
Returns
1 if set, 0 if unset

Definition at line 338 of file null_val.c.

References G_fatal_error().

Referenced by G__set_flags_from_01_random().

void Rast__convert_01_flags ( const char *  zero_ones,
unsigned char *  flags,
int  n 
)

?

Note: Only for internal use.

Parameters
zero_ones
flags
n

Definition at line 423 of file null_val.c.

References count, and Rast__null_bitstream_size().

Referenced by G__set_flags_from_01_random().

void Rast__convert_flags_01 ( char *  zero_ones,
const unsigned char *  flags,
int  n 
)

?

Note: Only for internal use.

Parameters
zero_ones
flags
n

Definition at line 461 of file null_val.c.

References count, and Rast__null_bitstream_size().

void Rast__init_null_bits ( unsigned char *  flags,
int  cols 
)

?

Note: Only for internal use.

Parameters
flags
cols

Definition at line 495 of file null_val.c.

References Rast__null_bitstream_size().

Referenced by Rast__read_null_bits().

void Rast__set_null_value ( void *  rast,
int  numVals,
int  null_is_zero,
RASTER_MAP_TYPE  data_type 
)

To set one or more raster values to null.

It also sets null to zero if null_is_zero is TRUE.

Parameters
rastpointer to values to set to null
numValsnumber of values to set to null
null_is_zeroflag to indicate if NULL = 0
data_typetype of raster - CELL, FCELL, DCELL

Definition at line 80 of file null_val.c.

References G_zero(), Rast_cell_size(), and Rast_set_null_value().

void Rast_insert_c_null_values ( CELL cellVal,
char *  null_row,
int  ncols 
)

To insert null values into an integer raster map (CELL)

For each of the count flags which is true(!=0), set the corresponding cell to the NULL value.

Parameters
rastpointer raster values
null_rownull row
ncolsnumber of columns

Definition at line 295 of file null_val.c.

References CELL_TYPE.

void Rast_insert_d_null_values ( DCELL dcellVal,
char *  null_row,
int  ncols 
)

To insert null values into an floating-point raster map (FCELL)

For each for the count flag which is true(!=0), set the corresponding dcell to the NULL value.

Parameters
dcellValpointer raster values
null_rownull row
ncolsnumber of columns

Definition at line 322 of file null_val.c.

References DCELL_TYPE.

void Rast_insert_f_null_values ( FCELL fcellVal,
char *  null_row,
int  ncols 
)

To insert null values into an floating-point raster map (FCELL)

Parameters
fcellValpointer raster values
null_rownull row
ncolsnumber of columns

Definition at line 307 of file null_val.c.

References FCELL_TYPE.

void Rast_insert_null_values ( void *  rast,
char *  null_row,
int  ncols,
RASTER_MAP_TYPE  data_type 
)

To insert null values into a map.

Parameters
rastpointer raster values
null_rownull row
ncolsnumber of columns
data_typetype of raster - CELL, FCELL, DCELL

Definition at line 279 of file null_val.c.

int Rast_is_c_null_value ( const CELL cellVal)
int Rast_is_f_null_value ( const FCELL fcellVal)

To check if a FCELL raster value is set to NULL.

Returns 1 if fcell is NULL, 0 otherwise. This will test if the value fcell is a NaN. It isn't good enough to test for a particular NaN bit pattern since the machine code may change this bit pattern to a different NaN. The test will be

if(fcell==0.0) return 0;
if(fcell>0.0) return 0;
if(fcell<0.0) return 0;
return 1;

or (as suggested by Mark Line)

return (fcell != fcell);
Parameters
fcellValFCELL raster value to check
Returns
TRUE if FCELL raster value is NULL
FALSE otherwise

Definition at line 242 of file null_val.c.

Referenced by Gs_loadmap_as_float(), Gs_loadmap_as_int(), IL_resample_interp_segments_2d(), N_convert_array_2d_null_to_zero(), N_copy_array_2d(), N_norm_array_2d(), N_read_rast3d_to_array_3d(), N_read_rast_to_array_2d(), Rast3d_is_null_value_num(), Rast_fpreclass_perform_fd(), Rast_fpreclass_perform_ff(), Rast_fpreclass_perform_fi(), Rast_is_null_value(), Rast_quant_perform_f(), and Rast_set_f_value().

int Rast_is_null_value ( const void *  rast,
RASTER_MAP_TYPE  data_type 
)

To check if a raster value is set to NULL.

Parameters
rastraster value to check
data_typetype of raster - CELL, FCELL, DCELL
Returns
TRUE if raster value is NULL
FALSE otherwise

Definition at line 179 of file null_val.c.

References CELL_TYPE, DCELL_TYPE, FALSE, FCELL_TYPE, G_warning(), Rast_is_c_null_value(), Rast_is_d_null_value(), and Rast_is_f_null_value().

Referenced by D_draw_raster_RGB(), N_is_array_2d_value_null(), Rast__lookup_colors(), Rast_get_c_value(), Rast_get_cat(), Rast_get_d_value(), Rast_get_f_value(), Rast_get_row_colors(), Rast_get_vrt_row(), Rast_map_to_img_str(), Rast_raster_cmp(), and Rast_row_update_fp_range().

void Rast_set_c_null_value ( CELL cellVals,
int  numVals 
)

To set a number of CELL raster values to NULL.

Parameters
cellValspointer to CELL values to set to null
numValsnumber of values to set to null

Definition at line 124 of file null_val.c.

Referenced by N_copy_array_2d(), N_put_array_2d_value_null(), Rast_fpreclass_perform_di(), Rast_fpreclass_perform_fi(), Rast_fpreclass_perform_ii(), Rast_get_c_value(), Rast_get_range_min_max(), Rast_init_range(), Rast_quant_get_limits(), Rast_quant_perform_d(), Rast_quant_perform_f(), and Rast_set_null_value().

void Rast_set_f_null_value ( FCELL fcellVals,
int  numVals 
)

To set a number of FCELL raster values to NULL.

Parameters
fcellValspointer to FCELL values to set to null
numValsnumber of values to set to null

Definition at line 138 of file null_val.c.

Referenced by N_copy_array_2d(), N_put_array_2d_value_null(), Rast3d_set_null_value(), Rast_fpreclass_perform_df(), Rast_fpreclass_perform_ff(), Rast_fpreclass_perform_if(), Rast_get_f_value(), and Rast_set_null_value().

void Rast_set_null_value ( void *  buf,
int  numVals,
RASTER_MAP_TYPE  data_type 
)

To set one or more raster values to null.

Parameters
bufpointer to values to set to null
numValsnumber of values to set to null
data_typetype of raster - CELL, FCELL, DCELL

Definition at line 98 of file null_val.c.

References _, CELL_TYPE, DCELL_TYPE, FCELL_TYPE, G_warning(), Rast_set_c_null_value(), Rast_set_d_null_value(), and Rast_set_f_null_value().

Referenced by N_gwflow_2d_calc_water_budget(), N_gwflow_3d_calc_water_budget(), Rast3d_gradient_double(), Rast__set_null_value(), Rast_get_vrt_row(), Rast_set_c_value(), Rast_set_d_value(), and Rast_set_f_value().