GRASS GIS 8 Programmer's Manual  8.4.0dev(2024)-b656141cbc
defs/raster.h File Reference
#include <grass/gis.h>
Include dependency graph for defs/raster.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define Rast_is_c_null_value(cellVal)    (*(const CELL *)(cellVal) == (CELL)0x80000000)
 
#define Rast_is_f_null_value(fcellVal)    (*(const FCELL *)(fcellVal) != *(const FCELL *)(fcellVal))
 
#define Rast_is_d_null_value(dcellVal)    (*(const DCELL *)(dcellVal) != *(const DCELL *)(dcellVal))
 

Typedefs

typedef int read_rule_fn(void *, DCELL, DCELL, DCELL *, int *, int *, int *, int *, int *, int *)
 

Functions

void Rast_align_window (struct Cell_head *, const struct Cell_head *)
 Align two regions. More...
 
size_t Rast_cell_size (RASTER_MAP_TYPE)
 Returns size of a raster cell in bytes. More...
 
void * Rast_allocate_buf (RASTER_MAP_TYPE)
 Allocate memory for a raster map of given type. More...
 
CELLRast_allocate_c_buf (void)
 Allocate memory for a CELL type raster map. More...
 
FCELLRast_allocate_f_buf (void)
 Allocates memory for a raster map of type FCELL. More...
 
DCELLRast_allocate_d_buf (void)
 Allocates memory for a raster map of type DCELL. More...
 
char * Rast_allocate_null_buf (void)
 Allocates memory for a null buffer. More...
 
unsigned char * Rast__allocate_null_bits (int)
 Allocates memory for null bits. More...
 
int Rast__null_bitstream_size (int)
 Determines null bitstream size. More...
 
void * Rast_allocate_input_buf (RASTER_MAP_TYPE)
 
CELLRast_allocate_c_input_buf (void)
 
FCELLRast_allocate_f_input_buf (void)
 
DCELLRast_allocate_d_input_buf (void)
 
char * Rast_allocate_null_input_buf (void)
 
void * Rast_allocate_output_buf (RASTER_MAP_TYPE)
 
CELLRast_allocate_c_output_buf (void)
 
FCELLRast_allocate_f_output_buf (void)
 
DCELLRast_allocate_d_output_buf (void)
 
char * Rast_allocate_null_output_buf (void)
 
int Rast__check_for_auto_masking (void)
 Checks for auto masking. More...
 
void Rast_suppress_masking (void)
 Suppresses masking. More...
 
void Rast_unsuppress_masking (void)
 Unsuppresses masking. More...
 
int Rast_read_cats (const char *, const char *, struct Categories *)
 Read raster category file. More...
 
int Rast_read_vector_cats (const char *, const char *, struct Categories *)
 Read vector category file. More...
 
CELL Rast_get_max_c_cat (const char *, const char *)
 Get the max category number. More...
 
char * Rast_get_cats_title (const struct Categories *)
 Get title from category structure struct. More...
 
char * Rast_get_c_cat (CELL *, struct Categories *)
 Get a raster category label (CELL) More...
 
char * Rast_get_f_cat (FCELL *, struct Categories *)
 Get a raster category label (FCELL) More...
 
char * Rast_get_d_cat (DCELL *, struct Categories *)
 Get a raster category label (DCELL) More...
 
char * Rast_get_cat (void *, struct Categories *, RASTER_MAP_TYPE)
 Get a raster category label. More...
 
void Rast_unmark_cats (struct Categories *)
 Sets marks for all categories to 0. More...
 
void Rast_mark_c_cats (const CELL *, int, struct Categories *)
 Looks up the category label for each raster value (CELL). More...
 
void Rast_mark_f_cats (const FCELL *, int, struct Categories *)
 Looks up the category label for each raster value (FCELL). More...
 
void Rast_mark_d_cats (const DCELL *, int, struct Categories *)
 Looks up the category label for each raster value (DCELL). More...
 
int Rast_mark_cats (const void *, int, struct Categories *, RASTER_MAP_TYPE)
 Looks up the category label for each raster value (DCELL). More...
 
void Rast_rewind_cats (struct Categories *)
 Rewind raster categories. More...
 
char * Rast_get_next_marked_d_cat (struct Categories *, DCELL *, DCELL *, long *)
 Get next marked raster categories (DCELL) More...
 
char * Rast_get_next_marked_c_cat (struct Categories *, CELL *, CELL *, long *)
 Get next marked raster categories (CELL) More...
 
char * Rast_get_next_marked_f_cat (struct Categories *, FCELL *, FCELL *, long *)
 Get next marked raster categories (FCELL) More...
 
char * Rast_get_next_marked_cat (struct Categories *, void *, void *, long *, RASTER_MAP_TYPE)
 Get next marked raster categories. More...
 
int Rast_set_c_cat (const CELL *, const CELL *, const char *, struct Categories *)
 Set a raster category label (CELL) More...
 
int Rast_set_f_cat (const FCELL *, const FCELL *, const char *, struct Categories *)
 Set a raster category label (FCELL) More...
 
int Rast_set_d_cat (const DCELL *, const DCELL *, const char *, struct Categories *)
 Set a raster category label (DCELL) More...
 
int Rast_set_cat (const void *, const void *, const char *, struct Categories *, RASTER_MAP_TYPE)
 Set a raster category label. More...
 
void Rast_write_cats (const char *, struct Categories *)
 Write raster category file. More...
 
void Rast_write_vector_cats (const char *, struct Categories *)
 Write vector category file. More...
 
char * Rast_get_ith_d_cat (const struct Categories *, int, DCELL *, DCELL *)
 Get category description (DCELL) More...
 
char * Rast_get_ith_f_cat (const struct Categories *, int, void *, void *)
 Get category description (FCELL) More...
 
char * Rast_get_ith_c_cat (const struct Categories *, int, void *, void *)
 Get category description (CELL) More...
 
char * Rast_get_ith_cat (const struct Categories *, int, void *, void *, RASTER_MAP_TYPE)
 Get category description. More...
 
void Rast_init_cats (const char *, struct Categories *)
 Initialize category structure. More...
 
void Rast_set_cats_title (const char *, struct Categories *)
 Set title in category structure. More...
 
void Rast_set_cats_fmt (const char *, double, double, double, double, struct Categories *)
 Set category fmt (?) More...
 
void Rast_free_cats (struct Categories *)
 Free category structure memory. More...
 
void Rast_copy_cats (struct Categories *, const struct Categories *)
 Copy raster categories. More...
 
int Rast_number_of_cats (struct Categories *)
 Get number of raster categories. More...
 
int Rast_sort_cats (struct Categories *)
 Sort categories. More...
 
void Rast_init_cell_stats (struct Cell_stats *)
 Initialize cell stats. More...
 
int Rast_update_cell_stats (const CELL *, int, struct Cell_stats *)
 Add data to cell stats. More...
 
int Rast_find_cell_stat (CELL, long *, const struct Cell_stats *)
 Random query of cell stats. More...
 
int Rast_rewind_cell_stats (struct Cell_stats *)
 Reset/rewind cell stats. More...
 
int Rast_next_cell_stat (CELL *, long *, struct Cell_stats *)
 Retrieve sorted cell stats. More...
 
void Rast_get_stats_for_null_value (long *, const struct Cell_stats *)
 Get number of null values. More...
 
void Rast_free_cell_stats (struct Cell_stats *)
 Free cell stats structure. More...
 
char * Rast_get_cell_title (const char *, const char *)
 get raster map title More...
 
int Rast_cell_stats_histo_eq (struct Cell_stats *, CELL, CELL, CELL, CELL, int, void(*)(CELL, CELL, CELL))
 
void Rast_close (int)
 Close a raster map. More...
 
void Rast_unopen (int)
 Unopen a raster map. More...
 
void Rast__unopen_all (void)
 Unopen all raster maps. More...
 
void Rast__close_null (int)
 
void Rast_make_ryg_colors (struct Colors *, CELL, CELL)
 Create RYG color table (integer) More...
 
void Rast_make_ryg_fp_colors (struct Colors *, DCELL, DCELL)
 Create RYG color table (floating-point) More...
 
void Rast_make_aspect_colors (struct Colors *, CELL, CELL)
 Make aspect colors (integer) More...
 
void Rast_make_aspect_fp_colors (struct Colors *, DCELL, DCELL)
 Make aspect colors (floating-point) More...
 
void Rast_make_byr_colors (struct Colors *, CELL, CELL)
 Create BYR color table (integer) More...
 
void Rast_make_byr_fp_colors (struct Colors *, DCELL, DCELL)
 Create BYR color table (floating-point) More...
 
void Rast_make_bgyr_colors (struct Colors *, CELL, CELL)
 Create BGYR color table (integer) More...
 
void Rast_make_bgyr_fp_colors (struct Colors *, DCELL, DCELL)
 Create BGYR color table (floating-point) More...
 
void Rast_make_byg_colors (struct Colors *, CELL, CELL)
 Create BYG color table (integer) More...
 
void Rast_make_byg_fp_colors (struct Colors *, DCELL, DCELL)
 Create BYG color table (floating-point) More...
 
void Rast_make_grey_scale_colors (struct Colors *, CELL, CELL)
 Make linear grey scale (integer) More...
 
void Rast_make_grey_scale_fp_colors (struct Colors *, DCELL, DCELL)
 Make linear grey scale (floating-point) More...
 
void Rast_make_gyr_colors (struct Colors *, CELL, CELL)
 Create GYR color table (integer) More...
 
void Rast_make_gyr_fp_colors (struct Colors *, DCELL, DCELL)
 Create GYR color table (floating-point) More...
 
void Rast_make_rainbow_colors (struct Colors *, CELL, CELL)
 Make rainbow colors (integer) More...
 
void Rast_make_rainbow_fp_colors (struct Colors *, DCELL, DCELL)
 Make rainbow colors (floating-point) More...
 
void Rast_make_ramp_colors (struct Colors *, CELL, CELL)
 Make color ramp (integer) More...
 
void Rast_make_ramp_fp_colors (struct Colors *, DCELL, DCELL)
 Make color ramp (floating-point) More...
 
void Rast_make_wave_colors (struct Colors *, CELL, CELL)
 Make color wave (integer) More...
 
void Rast_make_wave_fp_colors (struct Colors *, DCELL, DCELL)
 Make color wave (floating-point) More...
 
void Rast_free_colors (struct Colors *)
 Free color structure memory. More...
 
void Rast__color_free_rules (struct _Color_Info_ *)
 Free color rules structure. More...
 
void Rast__color_free_lookup (struct _Color_Info_ *)
 Free color rules structure. More...
 
void Rast__color_free_fp_lookup (struct _Color_Info_ *)
 Free color rules structure. More...
 
void Rast__color_reset (struct Colors *)
 Reset colors structure. More...
 
int Rast_get_color (const void *, int *, int *, int *, struct Colors *, RASTER_MAP_TYPE)
 Gets color from raster map. More...
 
int Rast_get_c_color (const CELL *, int *, int *, int *, struct Colors *)
 Gets color from raster map (CELL) More...
 
int Rast_get_f_color (const FCELL *, int *, int *, int *, struct Colors *)
 Gets color from raster map (FCELL) More...
 
int Rast_get_d_color (const DCELL *, int *, int *, int *, struct Colors *)
 Gets color from raster map (DCELL) More...
 
void Rast_get_null_value_color (int *, int *, int *, const struct Colors *)
 Gets color for null value. More...
 
void Rast_get_default_color (int *, int *, int *, const struct Colors *)
 Gets default color. More...
 
void Rast_make_histogram_eq_colors (struct Colors *, struct Cell_stats *)
 Make histogram-stretched grey colors. More...
 
void Rast_make_histogram_log_colors (struct Colors *, struct Cell_stats *, int, int)
 Generates histogram with normalized log transformed grey scale. More...
 
void Rast_init_colors (struct Colors *)
 Initialize color structure. More...
 
int Rast__insert_color_into_lookup (CELL, int, int, int, struct _Color_Info_ *)
 
void Rast_invert_colors (struct Colors *)
 
void Rast_lookup_c_colors (const CELL *, unsigned char *, unsigned char *, unsigned char *, unsigned char *, int, struct Colors *)
 Lookup an array of colors. More...
 
void Rast_lookup_colors (const void *, unsigned char *, unsigned char *, unsigned char *, unsigned char *, int, struct Colors *, RASTER_MAP_TYPE)
 Lookup an array of colors. More...
 
void Rast_lookup_f_colors (const FCELL *, unsigned char *, unsigned char *, unsigned char *, unsigned char *, int, struct Colors *)
 Lookup an array of colors (FCELL) More...
 
void Rast_lookup_d_colors (const DCELL *, unsigned char *, unsigned char *, unsigned char *, unsigned char *, int, struct Colors *)
 Lookup an array of colors (DCELL) More...
 
void Rast__lookup_colors (const void *, unsigned char *, unsigned char *, unsigned char *, unsigned char *, int, struct Colors *, int, int, RASTER_MAP_TYPE)
 Lookup an array of colors. More...
 
void Rast__interpolate_color_rule (DCELL, unsigned char *, unsigned char *, unsigned char *, const struct _Color_Rule_ *)
 Interpolate color rules. More...
 
void Rast__organize_colors (struct Colors *)
 
void Rast_print_colors (struct Colors *, DCELL, DCELL, FILE *, int)
 Print color table. More...
 
void Rast_make_random_colors (struct Colors *, CELL, CELL)
 make random colors More...
 
void Rast_set_c_color_range (CELL, CELL, struct Colors *)
 Set color range (CELL version) More...
 
void Rast_set_d_color_range (DCELL, DCELL, struct Colors *)
 Set color range (DCELL version) More...
 
void Rast_get_c_color_range (CELL *, CELL *, const struct Colors *)
 Get color range values (CELL) More...
 
void Rast_get_d_color_range (DCELL *, DCELL *, const struct Colors *)
 Get color range values (DCELL) More...
 
int Rast_read_colors (const char *, const char *, struct Colors *)
 Read color table of raster map. More...
 
int Rast__read_colors (const char *, const char *, const char *, struct Colors *)
 
void Rast_mark_colors_as_fp (struct Colors *)
 Mark colors as floating-point. More...
 
int Rast_remove_colors (const char *, const char *)
 Remove color table of raster map. More...
 
void Rast_add_d_color_rule (const DCELL *, int, int, int, const DCELL *, int, int, int, struct Colors *)
 Adds the floating-point color rule (DCELL version) More...
 
void Rast_add_f_color_rule (const FCELL *, int, int, int, const FCELL *, int, int, int, struct Colors *)
 Adds the floating-point color rule (FCELL version) More...
 
void Rast_add_c_color_rule (const CELL *, int, int, int, const CELL *, int, int, int, struct Colors *)
 Adds the integer color rule (CELL version) More...
 
void Rast_add_color_rule (const void *, int, int, int, const void *, int, int, int, struct Colors *, RASTER_MAP_TYPE)
 Adds the color rule. More...
 
int Rast_add_modular_d_color_rule (const DCELL *, int, int, int, const DCELL *, int, int, int, struct Colors *)
 Add modular floating-point color rule (DCELL version) More...
 
int Rast_add_modular_f_color_rule (const FCELL *, int, int, int, const FCELL *, int, int, int, struct Colors *)
 Add modular floating-point color rule (FCELL version) More...
 
int Rast_add_modular_c_color_rule (const CELL *, int, int, int, const CELL *, int, int, int, struct Colors *)
 Add modular integer color rule (CELL version) More...
 
int Rast_add_modular_color_rule (const void *, int, int, int, const void *, int, int, int, struct Colors *, RASTER_MAP_TYPE)
 Add modular color rule. More...
 
int Rast_colors_count (const struct Colors *)
 Get both modular and fixed rules count. More...
 
int Rast_get_fp_color_rule (DCELL *, unsigned char *, unsigned char *, unsigned char *, DCELL *, unsigned char *, unsigned char *, unsigned char *, const struct Colors *, int)
 Get color rule from both modular and fixed rules. More...
 
int Rast_parse_color_rule (DCELL, DCELL, const char *, DCELL *, int *, int *, int *, int *, int *, int *)
 Read color rule. More...
 
const char * Rast_parse_color_rule_error (int)
 Parse color rule. More...
 
int Rast_read_color_rule (void *, DCELL, DCELL, DCELL *, int *, int *, int *, int *, int *, int *)
 Read color rule. More...
 
int Rast_read_color_rules (struct Colors *, DCELL, DCELL, read_rule_fn *, void *)
 Read color rules from file. More...
 
int Rast_load_colors (struct Colors *, const char *, CELL, CELL)
 Load color rules from file. More...
 
int Rast_load_fp_colors (struct Colors *, const char *, DCELL, DCELL)
 Load color floating-point rules from file. More...
 
void Rast_make_colors (struct Colors *, const char *, CELL, CELL)
 Load color rules from predefined color table. More...
 
void Rast_make_fp_colors (struct Colors *, const char *, DCELL, DCELL)
 Load color rules from predefined floating-point color table. More...
 
void Rast_set_c_color (CELL, int, int, int, struct Colors *)
 Set a category color (CELL) More...
 
void Rast_set_d_color (DCELL, int, int, int, struct Colors *)
 Set a category color (DCELL) More...
 
void Rast_set_null_value_color (int, int, int, struct Colors *)
 Set color for NULL-value. More...
 
void Rast_set_default_color (int, int, int, struct Colors *)
 Set default color value. More...
 
void Rast_shift_c_colors (CELL, struct Colors *)
 
void Rast_shift_d_colors (DCELL, struct Colors *)
 
void Rast_write_colors (const char *, const char *, struct Colors *)
 Write map layer color table. More...
 
void Rast__write_colors (FILE *, struct Colors *)
 Write map layer color table. More...
 
void Rast_histogram_eq_colors (struct Colors *, struct Colors *, struct Cell_stats *)
 Make histogram-stretched version of existing color table. More...
 
void Rast_histogram_eq_fp_colors (struct Colors *, struct Colors *, struct FP_stats *)
 Make histogram-stretched version of existing color table (FP version) More...
 
void Rast_log_colors (struct Colors *, struct Colors *, int)
 Make logarithmically-scaled version of an existing color table. More...
 
void Rast_abs_log_colors (struct Colors *, struct Colors *, int)
 Make logarithmically-scaled version of an existing color table, allowing for signed values. More...
 
int Rast__check_format (int)
 
int Rast__read_row_ptrs (int)
 
int Rast__read_null_row_ptrs (int, int)
 
int Rast__write_row_ptrs (int)
 
int Rast__write_null_row_ptrs (int, int)
 
void Rast_fpreclass_clear (struct FPReclass *)
 
void Rast_fpreclass_reset (struct FPReclass *)
 
void Rast_fpreclass_init (struct FPReclass *)
 
void Rast_fpreclass_set_domain (struct FPReclass *, DCELL, DCELL)
 
void Rast_fpreclass_set_range (struct FPReclass *, DCELL, DCELL)
 
int Rast_fpreclass_get_limits (const struct FPReclass *, DCELL *, DCELL *, DCELL *, DCELL *)
 
int Rast_fpreclass_nof_rules (const struct FPReclass *)
 
void Rast_fpreclass_get_ith_rule (const struct FPReclass *, int, DCELL *, DCELL *, DCELL *, DCELL *)
 
void Rast_fpreclass_set_neg_infinite_rule (struct FPReclass *, DCELL, DCELL)
 
int Rast_fpreclass_get_neg_infinite_rule (const struct FPReclass *, DCELL *, DCELL *)
 
void Rast_fpreclass_set_pos_infinite_rule (struct FPReclass *, DCELL, DCELL)
 
int Rast_fpreclass_get_pos_infinite_rule (const struct FPReclass *, DCELL *, DCELL *)
 
void Rast_fpreclass_add_rule (struct FPReclass *, DCELL, DCELL, DCELL, DCELL)
 
void Rast_fpreclass_reverse_rule_order (struct FPReclass *)
 
DCELL Rast_fpreclass_get_cell_value (const struct FPReclass *, DCELL)
 
void Rast_fpreclass_perform_di (const struct FPReclass *, const DCELL *, CELL *, int)
 
void Rast_fpreclass_perform_df (const struct FPReclass *, const DCELL *, FCELL *, int)
 
void Rast_fpreclass_perform_dd (const struct FPReclass *, const DCELL *, DCELL *, int)
 
void Rast_fpreclass_perform_fi (const struct FPReclass *, const FCELL *, CELL *, int)
 
void Rast_fpreclass_perform_ff (const struct FPReclass *, const FCELL *, FCELL *, int)
 
void Rast_fpreclass_perform_fd (const struct FPReclass *, const FCELL *, DCELL *, int)
 
void Rast_fpreclass_perform_ii (const struct FPReclass *, const CELL *, CELL *, int)
 
void Rast_fpreclass_perform_if (const struct FPReclass *, const CELL *, FCELL *, int)
 
void Rast_fpreclass_perform_id (const struct FPReclass *, const CELL *, DCELL *, int)
 
void Rast_init_gdal (void)
 Initialization. More...
 
struct GDAL_linkRast_get_gdal_link (const char *, const char *)
 Get GDAL link settings for given raster map. More...
 
struct GDAL_linkRast_create_gdal_link (const char *, RASTER_MAP_TYPE)
 Create GDAL settings for given raster map. More...
 
void Rast_close_gdal_link (struct GDAL_link *)
 Close existing GDAL link. More...
 
int Rast_close_gdal_write_link (struct GDAL_link *)
 Close existing GDAL link and write out data. More...
 
void Rast_get_cellhd (const char *, const char *, struct Cell_head *)
 Read the raster header. More...
 
void Rast_get_row_nomask (int, void *, int, RASTER_MAP_TYPE)
 Read raster row without masking. More...
 
void Rast_get_c_row_nomask (int, CELL *, int)
 Read raster row without masking (CELL type) More...
 
void Rast_get_f_row_nomask (int, FCELL *, int)
 Read raster row without masking (FCELL type) More...
 
void Rast_get_d_row_nomask (int, DCELL *, int)
 Read raster row without masking (DCELL type) More...
 
void Rast_get_row (int, void *, int, RASTER_MAP_TYPE)
 Get raster row. More...
 
void Rast_get_c_row (int, CELL *, int)
 Get raster row (CELL type) More...
 
void Rast_get_f_row (int, FCELL *, int)
 Get raster row (FCELL type) More...
 
void Rast_get_d_row (int, DCELL *, int)
 Get raster row (DCELL type) More...
 
void Rast_get_null_value_row (int, char *, int)
 Read or simulate null value row. More...
 
int Rast__read_null_bits (int, int, unsigned char *)
 
void Rast_get_row_colors (int, int, struct Colors *, unsigned char *, unsigned char *, unsigned char *, unsigned char *)
 Reads a row of raster data and converts it to RGB. More...
 
void Rast_histogram_eq (const struct Histogram *, unsigned char **, CELL *, CELL *)
 
void Rast_init_histogram (struct Histogram *)
 initializes the histogram structure More...
 
int Rast_read_histogram (const char *, const char *, struct Histogram *)
 read the histogram information More...
 
void Rast_write_histogram (const char *, const struct Histogram *)
 Writes the histogram information. More...
 
void Rast_write_histogram_cs (const char *, struct Cell_stats *)
 Writes the histogram based on cell statistics to file. More...
 
void Rast_make_histogram_cs (struct Cell_stats *, struct Histogram *)
 Creates histogram based on cell statistics. More...
 
int Rast_get_histogram_num (const struct Histogram *)
 Sorts the histogram in ascending order by counts then category. More...
 
CELL Rast_get_histogram_cat (int, const struct Histogram *)
 Returns cat for the nth element in the histogram. More...
 
long Rast_get_histogram_count (int, const struct Histogram *)
 Returns count for the nth element in the histogram. More...
 
void Rast_free_histogram (struct Histogram *)
 Frees memory allocated for the histogram. More...
 
int Rast_sort_histogram (struct Histogram *)
 Sorts the histogram. More...
 
int Rast_sort_histogram_by_count (struct Histogram *)
 Sorts the histogram by counts. More...
 
void Rast_remove_histogram (const char *)
 Removes the histogram. More...
 
int Rast_add_histogram (CELL, long, struct Histogram *)
 adds count to the histogram value for cat More...
 
int Rast_set_histogram (CELL, long, struct Histogram *)
 sets the histogram value for cat to count More...
 
void Rast_extend_histogram (CELL, long, struct Histogram *)
 Extends histogram struct to accommodate a new value. More...
 
void Rast_zero_histogram (struct Histogram *)
 Zero out histogram struct. More...
 
int Rast__read_history (struct History *, FILE *)
 
int Rast_read_history (const char *, const char *, struct History *)
 Read raster history file. More...
 
void Rast__write_history (struct History *, FILE *)
 
void Rast_write_history (const char *, struct History *)
 Write raster history file. More...
 
void Rast_short_history (const char *, const char *, struct History *)
 Initialize history structure. More...
 
int Rast_command_history (struct History *)
 Save command line to raster history structure. More...
 
void Rast_append_history (struct History *, const char *)
 Append a string to a History structure. More...
 
void Rast_append_format_history (struct History *, const char *,...) __attribute__((format(printf
 
void const char * Rast_get_history (struct History *, int)
 Set the string of a specific history field. More...
 
void Rast_set_history (struct History *, int, const char *)
 Set the string of a specific history field. More...
 
void Rast_format_history (struct History *, int, const char *,...) __attribute__((format(printf
 
void void Rast_clear_history (struct History *)
 
void Rast_free_history (struct History *)
 
int Rast_history_length (struct History *)
 
const char * Rast_history_line (struct History *, int)
 
void Rast_init (void)
 Initialize GRASS GIS engine. More...
 
void Rast__check_init (void)
 Checks to see if GIS engine is initialized. More...
 
void Rast_init_all (void)
 
void Rast__init (void)
 
void Rast__error_handler (void *)
 
DCELL Rast_interp_linear (double, DCELL, DCELL)
 
DCELL Rast_interp_bilinear (double, double, DCELL, DCELL, DCELL, DCELL)
 
DCELL Rast_interp_cubic (double, DCELL, DCELL, DCELL, DCELL)
 
DCELL Rast_interp_bicubic (double, double, DCELL, DCELL, DCELL, DCELL, DCELL, DCELL, DCELL, DCELL, DCELL, DCELL, DCELL, DCELL, DCELL, DCELL, DCELL, DCELL)
 
DCELL Rast_interp_lanczos (double, double, DCELL *)
 
DCELL Rast_interp_cubic_bspline (double, DCELL, DCELL, DCELL, DCELL)
 
DCELL Rast_interp_bicubic_bspline (double, double, DCELL, DCELL, DCELL, DCELL, DCELL, DCELL, DCELL, DCELL, DCELL, DCELL, DCELL, DCELL, DCELL, DCELL, DCELL, DCELL)
 
int Rast_option_to_interp_type (const struct Option *)
 Get interpolation method from the option. More...
 
char * Rast_mask_info (void)
 
int Rast__mask_info (char *, char *)
 
int Rast_maskfd (void)
 Test for MASK. More...
 
void Rast__set_null_value (void *, int, int, RASTER_MAP_TYPE)
 To set one or more raster values to null. More...
 
void Rast_set_null_value (void *, int, RASTER_MAP_TYPE)
 To set one or more raster values to null. More...
 
void Rast_set_c_null_value (CELL *, int)
 To set a number of CELL raster values to NULL. More...
 
void Rast_set_f_null_value (FCELL *, int)
 To set a number of FCELL raster values to NULL. More...
 
void Rast_set_d_null_value (DCELL *, int)
 To set a number of DCELL raster values to NULL. More...
 
int Rast_is_null_value (const void *, RASTER_MAP_TYPE)
 To check if a raster value is set to NULL. More...
 
void Rast_insert_null_values (void *, char *, int, RASTER_MAP_TYPE)
 To check if a CELL raster value is set to NULL. More...
 
void Rast_insert_c_null_values (CELL *, char *, int)
 To insert null values into an integer raster map (CELL) More...
 
void Rast_insert_f_null_values (FCELL *, char *, int)
 To insert null values into an floating-point raster map (FCELL) More...
 
void Rast_insert_d_null_values (DCELL *, char *, int)
 To insert null values into an floating-point raster map (FCELL) More...
 
int Rast__check_null_bit (const unsigned char *, int, int)
 Check NULL. More...
 
void Rast__convert_01_flags (const char *, unsigned char *, int)
 ? More...
 
void Rast__convert_flags_01 (char *, const unsigned char *, int)
 ? More...
 
void Rast__init_null_bits (unsigned char *, int)
 ? More...
 
int Rast_open_old (const char *, const char *)
 Open an existing integer raster map (cell) More...
 
int Rast__open_old (const char *, const char *)
 Lower level function, open cell files, supercell files, and the MASK file. More...
 
int Rast_open_c_new (const char *)
 Opens a new cell file in a database (compressed) More...
 
int Rast_open_c_new_uncompressed (const char *)
 Opens a new cell file in a database (uncompressed) More...
 
void Rast_want_histogram (int)
 Save histogram for newly create raster map (cell) More...
 
void Rast_set_cell_format (int)
 Sets the format for subsequent opens on new integer cell files (uncompressed and random only). More...
 
int Rast_get_cell_format (CELL)
 Get cell value format. More...
 
int Rast_open_fp_new (const char *)
 Opens new fcell file in a database. More...
 
int Rast_open_fp_new_uncompressed (const char *)
 Opens new fcell file in a database (uncompressed) More...
 
void Rast_set_fp_type (RASTER_MAP_TYPE)
 Set raster map floating-point data format. More...
 
int Rast_map_is_fp (const char *, const char *)
 Check if raster map is floating-point. More...
 
RASTER_MAP_TYPE Rast_map_type (const char *, const char *)
 Determine raster data type. More...
 
RASTER_MAP_TYPE Rast__check_fp_type (const char *, const char *)
 Determines whether the floating points cell file has double or float type. More...
 
RASTER_MAP_TYPE Rast_get_map_type (int)
 Determine raster type from descriptor. More...
 
int Rast_open_new (const char *, RASTER_MAP_TYPE)
 Opens a new raster map. More...
 
int Rast_open_new_uncompressed (const char *, RASTER_MAP_TYPE)
 Opens a new raster map (uncompressed) More...
 
void Rast_set_quant_rules (int, struct Quant *)
 Sets quant translation rules for raster map opened for reading. More...
 
int Rast__open_null_write (const char *)
 
void Rast_put_cellhd (const char *, struct Cell_head *)
 Writes the raster file header. More...
 
void Rast_put_row (int, const void *, RASTER_MAP_TYPE)
 Writes the next row for cell/fcell/dcell file. More...
 
void Rast_put_c_row (int, const CELL *)
 Writes the next row for cell file (CELL version) More...
 
void Rast_put_f_row (int, const FCELL *)
 Writes the next row for fcell file (FCELL version) More...
 
void Rast_put_d_row (int, const DCELL *)
 Writes the next row for dcell file (DCELL version) More...
 
void Rast__write_null_bits (int, const unsigned char *)
 Write null data. More...
 
int Rast_put_cell_title (const char *, const char *)
 
void Rast_quant_clear (struct Quant *)
 Resets the number of defined rules and number of infinite rules to 0. More...
 
void Rast_quant_free (struct Quant *)
 Resets and frees allocated memory. More...
 
int Rast__quant_organize_fp_lookup (struct Quant *)
 Organized fp_lookup table. More...
 
void Rast_quant_init (struct Quant *)
 Initialize the structure. More...
 
int Rast_quant_is_truncate (const struct Quant *)
 Returns whether or not quant rules are set to truncate map. More...
 
int Rast_quant_is_round (const struct Quant *)
 Returns whether or not quant rules are set to round map. More...
 
void Rast_quant_truncate (struct Quant *)
 Sets the quant rules to perform simple truncation on floats. More...
 
void Rast_quant_round (struct Quant *)
 Sets the quant rules to perform simple rounding on floats. More...
 
int Rast_quant_get_limits (const struct Quant *, DCELL *, DCELL *, CELL *, CELL *)
 Returns the minimum and maximum cell and dcell values of all the ranges defined. More...
 
int Rast_quant_nof_rules (const struct Quant *)
 Returns the number of quantization rules defined. More...
 
void Rast_quant_get_ith_rule (const struct Quant *, int, DCELL *, DCELL *, CELL *, CELL *)
 Returns the i'th quantization rule. More...
 
void Rast_quant_set_neg_infinite_rule (struct Quant *, DCELL, CELL)
 Defines a rule for values "dLeft" and smaller. More...
 
int Rast_quant_get_neg_infinite_rule (const struct Quant *, DCELL *, CELL *)
 Returns in "dLeft" and "c" the rule values. More...
 
void Rast_quant_set_pos_infinite_rule (struct Quant *, DCELL, CELL)
 Defines a rule for values "dRight" and larger. More...
 
int Rast_quant_get_pos_infinite_rule (const struct Quant *, DCELL *, CELL *)
 Returns in "dRight" and "c" the rule values. More...
 
void Rast_quant_add_rule (struct Quant *, DCELL, DCELL, CELL, CELL)
 Adds a new rule to the set of quantization rules. More...
 
void Rast_quant_reverse_rule_order (struct Quant *)
 Rreverses the order in which the qunatization rules are stored. More...
 
CELL Rast_quant_get_cell_value (struct Quant *, DCELL)
 Returns a CELL category for the floating-point value based on the quantization rules in q. The first rule found that applies is used. The rules are searched in the reverse order they are added to q. If no rule is found, the value is first tested against the negative infinite rule, and finally against the positive infinite rule. If none of these rules apply, the NULL-value is returned. More...
 
void Rast_quant_perform_d (struct Quant *, const DCELL *, CELL *, int)
 Returns in "cell" the quantized CELL values. More...
 
void Rast_quant_perform_f (struct Quant *, const FCELL *, CELL *, int)
 Same as Rast_quant_perform_d(), except the type. More...
 
struct Quant_tableRast__quant_get_rule_for_d_raster_val (const struct Quant *, DCELL)
 Returns quant rule which will be applied. More...
 
int Rast__quant_import (const char *, const char *, struct Quant *)
 Reads quantization rules (internal use only) More...
 
int Rast__quant_export (const char *, const char *, const struct Quant *)
 Writes the quantization rules (internal use only) More...
 
void Rast_truncate_fp_map (const char *, const char *)
 Writes the quant rules. More...
 
void Rast_round_fp_map (const char *, const char *)
 Writes the quant rules. More...
 
void Rast_quantize_fp_map (const char *, const char *, CELL, CELL)
 Write quant rules (f_quant) for floating-point raster map. More...
 
void Rast_quantize_fp_map_range (const char *, const char *, DCELL, DCELL, CELL, CELL)
 Write quant rules (f_quant) for floating-point raster map. More...
 
void Rast_write_quant (const char *, const char *, const struct Quant *)
 Writes the quant rule table for the raster map. More...
 
int Rast_read_quant (const char *, const char *, struct Quant *)
 Reads quantization rules for name in mapset and stores them in the quantization structure. If the map is in another mapset, first checks for quant2 table for this map in current mapset. More...
 
void Rast__remove_fp_range (const char *)
 Remove floating-point range. More...
 
void Rast_construct_default_range (struct Range *)
 Construct default range. More...
 
int Rast_read_fp_range (const char *, const char *, struct FPRange *)
 Read floating-point range. More...
 
int Rast_read_range (const char *, const char *, struct Range *)
 Read raster range (CELL) More...
 
void Rast_write_range (const char *, const struct Range *)
 Write raster range file. More...
 
void Rast_write_fp_range (const char *, const struct FPRange *)
 Write raster range file (floating-point) More...
 
void Rast_update_range (CELL, struct Range *)
 Update range structure (CELL) More...
 
void Rast_update_fp_range (DCELL, struct FPRange *)
 Update range structure (floating-point) More...
 
void Rast_row_update_range (const CELL *, int, struct Range *)
 Update range structure based on raster row (CELL) More...
 
void Rast__row_update_range (const CELL *, int, struct Range *, int)
 Update range structure based on raster row. More...
 
void Rast_row_update_fp_range (const void *, int, struct FPRange *, RASTER_MAP_TYPE)
 Update range structure based on raster row (floating-point) More...
 
void Rast_init_range (struct Range *)
 Initialize range structure. More...
 
void Rast_get_range_min_max (const struct Range *, CELL *, CELL *)
 Get range min and max. More...
 
void Rast_init_fp_range (struct FPRange *)
 Initialize fp range. More...
 
void Rast_get_fp_range_min_max (const struct FPRange *, DCELL *, DCELL *)
 Get minimum and maximum value from fp range. More...
 
int Rast_read_rstats (const char *, const char *, struct R_stats *)
 Read raster stats. More...
 
void Rast_write_rstats (const char *, const struct R_stats *)
 Write raster stats file. More...
 
int Rast_raster_cmp (const void *, const void *, RASTER_MAP_TYPE)
 Compares raster values. More...
 
void Rast_raster_cpy (void *, const void *, int, RASTER_MAP_TYPE)
 Copies raster values. More...
 
void Rast_set_c_value (void *, CELL, RASTER_MAP_TYPE)
 Places a CELL raster value. More...
 
void Rast_set_f_value (void *, FCELL, RASTER_MAP_TYPE)
 Places a FCELL raster value. More...
 
void Rast_set_d_value (void *, DCELL, RASTER_MAP_TYPE)
 Places a DCELL raster value. More...
 
CELL Rast_get_c_value (const void *, RASTER_MAP_TYPE)
 Retrieves the value of give type from pointer p. More...
 
FCELL Rast_get_f_value (const void *, RASTER_MAP_TYPE)
 Retrieves the value of given raster type from pointer p (FCELL) More...
 
DCELL Rast_get_d_value (const void *, RASTER_MAP_TYPE)
 Retrieves the value of given type from pointer p (DCELL) More...
 
char * Rast_read_units (const char *, const char *)
 Get a raster map's units metadata string. More...
 
char * Rast_read_vdatum (const char *, const char *)
 Get a raster map's vertical datum metadata string. More...
 
char * Rast_read_semantic_label (const char *, const char *)
 Get a raster map semantic label metadata string. More...
 
char * Rast_get_semantic_label_or_name (const char *, const char *)
 Get a raster map semantic label or fall back to its name. More...
 
void Rast_write_units (const char *, const char *)
 Write a string to a raster map's units metadata file. More...
 
void Rast_write_vdatum (const char *, const char *)
 Write a string into a raster's vertical datum metadata file. More...
 
void Rast_write_semantic_label (const char *, const char *)
 Write a string into a rasters semantic label metadata file. More...
 
bool Rast_legal_semantic_label (const char *)
 Check for legal semantic label. More...
 
int Rast_map_to_img_str (char *, int, unsigned char *)
 
int Rast_is_reclass (const char *, const char *, char *, char *)
 Check if raster map is reclassified. More...
 
int Rast_is_reclassed_to (const char *, const char *, int *, char ***)
 Get child reclass maps list. More...
 
int Rast_get_reclass (const char *, const char *, struct Reclass *)
 Get reclass. More...
 
void Rast_free_reclass (struct Reclass *)
 Free Reclass structure. More...
 
int Rast_put_reclass (const char *, const struct Reclass *)
 Put reclass. More...
 
DCELL Rast_get_sample_nearest (int, const struct Cell_head *, struct Categories *, double, double, int)
 Extract a cell value from raster map (neighbor interpolation) More...
 
DCELL Rast_get_sample_bilinear (int, const struct Cell_head *, struct Categories *, double, double, int)
 Extract a cell value from raster map (bilinear interpolation). More...
 
DCELL Rast_get_sample_cubic (int, const struct Cell_head *, struct Categories *, double, double, int)
 Extract a cell value from raster map (cubic interpolation). More...
 
DCELL Rast_get_sample (int, const struct Cell_head *, struct Categories *, double, double, int, INTERP_TYPE)
 Extract a cell value from raster map. More...
 
void Rast__init_window (void)
 
void Rast_set_window (struct Cell_head *)
 Establishes 'window' as the current working window. More...
 
void Rast_unset_window (void)
 Unset current window. More...
 
void Rast_set_output_window (struct Cell_head *)
 Establishes 'window' as the current working window for output. More...
 
void Rast_set_input_window (struct Cell_head *)
 Establishes 'window' as the current working window for input. More...
 
struct R_vrtRast_get_vrt (const char *, const char *)
 
void Rast_close_vrt (struct R_vrt *)
 
int Rast_get_vrt_row (int, void *, int, RASTER_MAP_TYPE)
 
void Rast_get_window (struct Cell_head *)
 Read the current window. More...
 
void Rast_get_input_window (struct Cell_head *)
 Read the current input window. More...
 
void Rast_get_output_window (struct Cell_head *)
 Read the current output window. More...
 
int Rast_window_rows (void)
 Number of rows in active window. More...
 
int Rast_window_cols (void)
 Number of columns in active window. More...
 
int Rast_input_window_rows (void)
 Number of rows in active input window. More...
 
int Rast_input_window_cols (void)
 Number of columns in active input window. More...
 
int Rast_output_window_rows (void)
 Number of rows in active output window. More...
 
int Rast_output_window_cols (void)
 Number of columns in active output window. More...
 
double Rast_northing_to_row (double, const struct Cell_head *)
 Northing to row. More...
 
double Rast_easting_to_col (double, const struct Cell_head *)
 Easting to column. More...
 
double Rast_row_to_northing (double, const struct Cell_head *)
 Row to northing. More...
 
double Rast_col_to_easting (double, const struct Cell_head *)
 Column to easting. More...
 
void Rast__create_window_mapping (int)
 Create window mapping. More...
 
int Rast_row_repeat_nomask (int, int)
 Loops rows until mismatch?. More...
 
void Rast_zero_buf (void *, RASTER_MAP_TYPE)
 Zero a raster buffer. More...
 
void Rast_zero_input_buf (void *, RASTER_MAP_TYPE)
 
void Rast_zero_output_buf (void *, RASTER_MAP_TYPE)
 

Macro Definition Documentation

◆ Rast_is_c_null_value

#define Rast_is_c_null_value (   cellVal)     (*(const CELL *)(cellVal) == (CELL)0x80000000)

Definition at line 401 of file defs/raster.h.

◆ Rast_is_d_null_value

#define Rast_is_d_null_value (   dcellVal)     (*(const DCELL *)(dcellVal) != *(const DCELL *)(dcellVal))

Definition at line 405 of file defs/raster.h.

◆ Rast_is_f_null_value

#define Rast_is_f_null_value (   fcellVal)     (*(const FCELL *)(fcellVal) != *(const FCELL *)(fcellVal))

Definition at line 403 of file defs/raster.h.

Typedef Documentation

◆ read_rule_fn

typedef int read_rule_fn(void *, DCELL, DCELL, DCELL *, int *, int *, int *, int *, int *, int *)

Definition at line 225 of file defs/raster.h.

Function Documentation

◆ Rast__allocate_null_bits()

unsigned char* Rast__allocate_null_bits ( int  cols)

Allocates memory for null bits.

Allocates an array of unsigned char based on cols.

Parameters
colsnumber of columns in region
Returns
pointer to allocated buffer

Definition at line 134 of file alloc_cell.c.

References G_calloc, and Rast__null_bitstream_size().

◆ Rast__check_for_auto_masking()

int Rast__check_for_auto_masking ( void  )

Checks for auto masking.

On first call, opens the mask file if declared and available and allocates buffer for reading mask rows. On second call, returns 0 or 1.

Returns
0 if mask unset or unavailable
1 if mask set and available and ready to use

Definition at line 35 of file auto_mask.c.

References _, R__::auto_mask, G_find_raster(), G_mapset(), G_projection(), G_warning(), G_zone(), R__::mask_fd, Cell_head::proj, Rast__init(), Rast__open_old(), Rast_get_cellhd(), Rast_unopen(), and Cell_head::zone.

Referenced by Rast_init_all(), Rast_maskfd(), Rast_open_old(), and Rast_unsuppress_masking().

◆ Rast__check_format()

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 64 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.

◆ Rast__check_fp_type()

RASTER_MAP_TYPE Rast__check_fp_type ( const char *  name,
const char *  mapset 
)

Determines whether the floating points cell file has double or float type.

Parameters
namemap name
mapsetmapset where map name lives
Returns
raster type (fcell, dcell)

Definition at line 948 of file raster/open.c.

References _, DCELL_TYPE, FCELL_TYPE, FORMAT_FILE, G_fatal_error(), G_file_name_misc(), G_find_key_value(), G_find_raster2(), G_free_key_value(), G_fully_qualified_name(), G_read_key_value_file(), G_warning(), GPATH_MAX, name, and NULL.

Referenced by Rast_map_type().

◆ Rast__check_init()

void Rast__check_init ( void  )

Checks to see if GIS engine is initialized.

Returns

Definition at line 54 of file raster/init.c.

◆ Rast__check_null_bit()

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 335 of file null_val.c.

References G_fatal_error().

◆ Rast__close_null()

◆ Rast__color_free_fp_lookup()

void Rast__color_free_fp_lookup ( struct _Color_Info_ cp)

Free color rules structure.

Note: Only for internal use.

Parameters
cppointer to _Color_Info structure

Definition at line 79 of file color_free.c.

References _Color_Info_::active, _Color_Info_::fp_lookup, G_free(), _Color_Info_::nalloc, _Color_Info_::rules, and _Color_Info_::vals.

◆ Rast__color_free_lookup()

void Rast__color_free_lookup ( struct _Color_Info_ cp)

Free color rules structure.

Note: Only for internal use.

Parameters
cppointer to _Color_Info structure

Definition at line 61 of file color_free.c.

References _Color_Info_::active, _Color_Info_::blu, G_free(), _Color_Info_::grn, _Color_Info_::lookup, _Color_Info_::red, and _Color_Info_::set.

◆ Rast__color_free_rules()

void Rast__color_free_rules ( struct _Color_Info_ cp)

Free color rules structure.

Note: Only for internal use.

Parameters
cppointer to _Color_Info structure

Definition at line 43 of file color_free.c.

◆ Rast__color_reset()

void Rast__color_reset ( struct Colors colors)

Reset colors structure.

Note: Only for internal use.

This routine should NOT init the colors.

Parameters
colorspointer to Colors structure

Definition at line 98 of file color_free.c.

◆ Rast__convert_01_flags()

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 420 of file null_val.c.

References count, and Rast__null_bitstream_size().

◆ Rast__convert_flags_01()

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 457 of file null_val.c.

References count, and Rast__null_bitstream_size().

◆ Rast__create_window_mapping()

void Rast__create_window_mapping ( int  fd)

Create window mapping.

Creates mapping from cell header into window. The boundaries and resolution of the two spaces do not have to be the same or aligned in any way.

Parameters
fdfile descriptor

Definition at line 31 of file raster/window_map.c.

References alloc_index, fileinfo::C1, fileinfo::C2, fileinfo::cellhd, fileinfo::col_map, Cell_head::cols, Cell_head::east, Cell_head::ew_res, R__::fileinfo, G_debug(), G_free(), Cell_head::north, Cell_head::ns_res, fileinfo::open_mode, OPEN_OLD, Cell_head::proj, PROJECTION_LL, R__::rd_window, Cell_head::west, and x.

◆ Rast__error_handler()

void Rast__error_handler ( void *  )

◆ Rast__init()

◆ Rast__init_null_bits()

void Rast__init_null_bits ( unsigned char *  flags,
int  cols 
)

?

Note: Only for internal use.

Parameters
flags
cols

Definition at line 490 of file null_val.c.

References Rast__null_bitstream_size().

◆ Rast__init_window()

◆ Rast__insert_color_into_lookup()

int Rast__insert_color_into_lookup ( CELL  cat,
int  red,
int  grn,
int  blu,
struct _Color_Info_ cp 
)

Definition at line 18 of file color_insrt.c.

◆ Rast__interpolate_color_rule()

void Rast__interpolate_color_rule ( DCELL  val,
unsigned char *  red,
unsigned char *  grn,
unsigned char *  blu,
const struct _Color_Rule_ rule 
)

Interpolate color rules.

Parameters
valraster cell value
[out]redred value
[out]grngreen value
[out]blublue value
rulepointer to _Color_Rule which holds color rules info

Definition at line 422 of file color_look.c.

References _Color_Value_::blu, _Color_Value_::grn, _Color_Rule_::high, _Color_Value_::red, and _Color_Value_::value.

◆ Rast__lookup_colors()

void Rast__lookup_colors ( const void *  raster,
unsigned char *  red,
unsigned char *  grn,
unsigned char *  blu,
unsigned char *  set,
int  n,
struct Colors colors,
int  mod,
int  rules_only,
RASTER_MAP_TYPE  data_type 
)

Lookup an array of colors.

Parameters
rasterraster cell value
[out]redred value
[out]grngreen value
[out]blublue value
setarray which indicates if color is set or not
nnumber of values
colorspointer to Colors structure which holds color info
mod
rules_only
data_typeraster type (CELL, FCELL, DCELL)

Definition at line 195 of file color_look.c.

◆ Rast__mask_info()

int Rast__mask_info ( char *  name,
char *  mapset 
)

Definition at line 56 of file mask_info.c.

References G_find_raster(), G_mapset(), GMAPSET_MAX, GNAME_MAX, name, Rast_is_reclass(), and strcpy.

Referenced by Rast_mask_info().

◆ Rast__null_bitstream_size()

int Rast__null_bitstream_size ( int  cols)

Determines null bitstream size.

Parameters
colsnumber of columns
Returns
size of null bitstream

Definition at line 147 of file alloc_cell.c.

References _, and G_fatal_error().

Referenced by Rast__allocate_null_bits(), Rast__convert_01_flags(), Rast__convert_flags_01(), Rast__init_null_bits(), and Rast__write_null_bits().

◆ Rast__open_null_write()

int Rast__open_null_write ( const char *  name)

◆ Rast__open_old()

int Rast__open_old ( const char *  name,
const char *  mapset 
)

Lower level function, open cell files, supercell files, and the MASK file.

Actions:

  • opens the named cell file, following reclass reference if named layer is a reclass layer.
  • creates the required mapping between the data and the window for use by the get_map_row family of routines.

Diagnostics: Errors other than actual open failure will cause a diagnostic to be delivered through G_warning() open failure messages are left to the calling routine since the masking logic will want to issue a different warning.

Note: This routine does NOT open the MASK layer. If it did we would get infinite recursion. This routine is called to open the mask by Rast__check_for_auto_masking() which is called by Rast_open_old().

Parameters
namemap name
mapsetmapset of cell file to be opened
Returns
open file descriptor

Definition at line 152 of file raster/open.c.

References _, CELL_TYPE, Cell_head::compressed, DCELL_TYPE, FCELL_TYPE, Cell_head::format, G_check_compressor(), G_compressor_name(), G_fatal_error(), G_find_raster2(), G_fully_qualified_name(), G_open_old(), G_projection_name(), G_unqualified_name(), GMAPSET_MAX, GNAME_MAX, Reclass::mapset, Reclass::name, name, Cell_head::proj, Rast__init(), Rast_get_cellhd(), Rast_get_gdal_link(), Rast_get_reclass(), Rast_get_vrt(), Rast_map_type(), R__::rd_window, XDR_DOUBLE_NBYTES, XDR_FLOAT_NBYTES, and Cell_head::zone.

Referenced by Rast__check_for_auto_masking(), Rast_get_vrt_row(), and Rast_open_old().

◆ Rast__organize_colors()

void Rast__organize_colors ( struct Colors colors)

Definition at line 12 of file color_org.c.

◆ Rast__quant_export()

int Rast__quant_export ( const char *  name,
const char *  mapset,
const struct Quant quant 
)

Writes the quantization rules (internal use only)

Writes the quantization rules stored in quant for name . If the mapset is the same as the current mapset, the quant file is created in 'cell_misc/name' directory, otherwise it is created in 'quant2/mapset' directory, much like writing colors for map in another mapset. The rules are written in decreasing order of priority (i.e. rules added earlier are written later).

Note: if no rules are defined an empty file is created.

Parameters
namemap name
mapsetmapset name
quantpointer to Quant structure
Returns
-1 if map name is not fully qualified or file could not be opened.
1 otherwise.

Definition at line 270 of file quant_io.c.

References G__make_mapset_element_misc(), G_fopen_new(), G_fopen_new_misc(), G_make_mapset_object_group(), G_mapset(), G_name_is_fully_qualified(), G_remove(), G_remove_misc(), GMAPSET_MAX, GNAME_MAX, name, and QUANT_FILE_NAME.

Referenced by Rast_write_quant().

◆ Rast__quant_get_rule_for_d_raster_val()

struct Quant_table* Rast__quant_get_rule_for_d_raster_val ( const struct Quant q,
DCELL  val 
)

Returns quant rule which will be applied.

Returns quant rule which will be applied when looking up the integer quant value for val (used when organizing fp_lookup).

Parameters
qpointer to Quant structure which holds quant rules info
valfp cell value
Returns
pointer to the Quant_table (color rule)
NULL otherwise

Definition at line 774 of file quant.c.

References Quant_table::dHigh, Quant_table::dLow, Quant::nofRules, NULL, and Quant::table.

◆ Rast__quant_import()

int Rast__quant_import ( const char *  name,
const char *  mapset,
struct Quant quant 
)

Reads quantization rules (internal use only)

Reads quantization rules for raster map name in mapset and stores them in the quantization structure "quant". If the map is in another mapset, first checks for quant2 table for this map in current mapset.

Note: in the case of negative return value, the result of using the quantization structure is not defined. in case of return value 0, calls to Rast_quant_perform_d() and Rast_quant_perform_f() return NO_DATA (see description of Rast_quant_perform_d() for more details). in case of return values 2 and 3, the explicit rule for quant is set: floating range is mapped to integer range.

Note: use Rast_quant_init() to allocate and initialize the quantization staructure quant before the first usage of G_quant_import().

Note: this function uses Rast_quant_free () to clear all previously stored rules in quant.

Parameters
namemap name
mapsetmapset name
[out]quantpointer to Quant structure
Returns
-2 if raster map is of type integer.
-1 if map name is fully qualified and mapset is not the current one
0 if quantization file does not exist, or the file is empty,
1 if non-empty quantization file exists.

Definition at line 95 of file quant_io.c.

References _, CELL_TYPE, G_fopen_old(), G_fully_qualified_name(), G_mapset(), G_name_is_fully_qualified(), G_warning(), GMAPSET_MAX, GNAME_MAX, name, Rast_map_type(), and Rast_quant_free().

Referenced by Rast_read_quant().

◆ Rast__quant_organize_fp_lookup()

int Rast__quant_organize_fp_lookup ( struct Quant q)

Organized fp_lookup table.

Organizes fp_lookup table for faster (logarithmic) lookup time G_quant_organize_fp_lookup() creates a list of min and max for each quant rule, sorts this list, and stores the pointer to quant rule that should be used in between any 2 numbers in this list. Also it stores extreme points for 2 infinite rules, if exist. After the call to G_quant_organize_fp_lookup() instead of linearly searching through list of rules to find a rule to apply, quant lookup will perform a binary search to find an interval containing floating point value, and then use the rule associated with this interval. when the value doesn't fall within any interval, check for the infinite rules.

Parameters
qpointer to Quant structure which holds quant rules info
Returns
1 on success

Definition at line 90 of file quant.c.

◆ Rast__read_colors()

int Rast__read_colors ( const char *  element,
const char *  name,
const char *  mapset,
struct Colors colors 
)

Definition at line 115 of file raster/color_read.c.

◆ Rast__read_history()

int Rast__read_history ( struct History hist,
FILE *  fp 
)

◆ Rast__read_null_bits()

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

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

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

◆ Rast__read_null_row_ptrs()

int Rast__read_null_row_ptrs ( int  fd,
int  null_fd 
)

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

References fileinfo::cellhd, R__::fileinfo, and Cell_head::rows.

◆ Rast__read_row_ptrs()

int Rast__read_row_ptrs ( int  fd)

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

References fileinfo::cellhd, Cell_head::compressed, R__::fileinfo, and Cell_head::rows.

Referenced by Rast__check_format().

◆ Rast__remove_fp_range()

void Rast__remove_fp_range ( const char *  name)

Remove floating-point range.

Note: For internal use only.

Parameters
namemap name

Definition at line 33 of file raster/range.c.

References G_remove_misc(), and name.

◆ Rast__row_update_range()

void Rast__row_update_range ( const CELL cell,
int  n,
struct Range range,
int  ignore_zeros 
)

Update range structure based on raster row.

Note: for internal use only.

Parameters
cellraster values
nnumber of values
rangepointer to Range structure which holds range info
ignore_zerosignore zeros

Definition at line 590 of file raster/range.c.

References R_stats::count, Range::first_time, Range::max, Range::min, min, Rast_is_c_null_value, Range::rstats, R_stats::sum, and R_stats::sumsq.

Referenced by Rast_row_update_range().

◆ Rast__set_null_value()

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().

◆ Rast__unopen_all()

void Rast__unopen_all ( void  )

Unopen all raster maps.

Unopen all raster maps opened for write. Memory allocated for raster processing is freed, and the temporary file created when the raster map was opened is removed (see Creating and Opening New Raster Files). This routine is useful when errors are detected and it is desired to remove temporary files.

Returns
void

Definition at line 156 of file raster/close.c.

References R__::fileinfo, R__::fileinfo_count, fileinfo::open_mode, OPEN_NEW_COMPRESSED, and OPEN_NEW_UNCOMPRESSED.

Referenced by Rast__error_handler().

◆ Rast__write_colors()

void Rast__write_colors ( FILE *  fd,
struct Colors colors 
)

Write map layer color table.

Parameters
fdfile descriptor
colorspointer to Colors structure which holds color info

Definition at line 109 of file raster/color_write.c.

◆ Rast__write_history()

void Rast__write_history ( struct History hist,
FILE *  fp 
)

◆ Rast__write_null_bits()

void Rast__write_null_bits ( int  fd,
const unsigned char *  flags 
)

Write null data.

Parameters
flags?
rowrow number
colcol number
fdfile descriptor of cell data file
Returns
void

Definition at line 553 of file raster/put_row.c.

References fileinfo::cellhd, Cell_head::cols, R__::fileinfo, fileinfo::null_cur_row, fileinfo::null_row_ptr, and Rast__null_bitstream_size().

◆ Rast__write_null_row_ptrs()

int Rast__write_null_row_ptrs ( int  fd,
int  null_fd 
)

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

References fileinfo::cellhd, R__::fileinfo, and Cell_head::rows.

Referenced by Rast__close_null().

◆ Rast__write_row_ptrs()

int Rast__write_row_ptrs ( int  fd)

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

References fileinfo::cellhd, R__::fileinfo, and Cell_head::rows.

◆ Rast_abs_log_colors()

void Rast_abs_log_colors ( struct Colors dst,
struct Colors src,
int  samples 
)

Make logarithmically-scaled version of an existing color table, allowing for signed values.

Parameters
[out]dststruct to hold new colors
srcstruct containing original colors
samplesnumber of samples

Definition at line 250 of file color_xform.c.

◆ Rast_add_c_color_rule()

void Rast_add_c_color_rule ( const CELL cat1,
int  r1,
int  g1,
int  b1,
const CELL cat2,
int  r2,
int  g2,
int  b2,
struct Colors colors 
)

Adds the integer color rule (CELL version)

See Rast_add_color_rule() for details.

Parameters
cat1cell value
r1,g1,b1color value
cat2cell value
r2,g2,b2color value
[in,out]colorspointer to color table structure

Definition at line 76 of file color_rule.c.

◆ Rast_add_color_rule()

void Rast_add_color_rule ( const void *  val1,
int  r1,
int  g1,
int  b1,
const void *  val2,
int  r2,
int  g2,
int  b2,
struct Colors colors,
RASTER_MAP_TYPE  data_type 
)

Adds the color rule.

Adds the floating-point rule that the range [v1,v2] gets a linear ramp of colors from [r1,g1,b1] to [r2,g2,b2]. If either v1 or v2 is the NULL-value, this call is converted ino Rast_set_null_value_color (r1, g1, b1, colors)

Parameters
val1cell value
r1,g1,b1color value
val2cell value
r2,g2,b2color value
[in,out]colorspointer to color table structure
data_typeraster data type (CELL, FCELL, DCELL)

Definition at line 104 of file color_rule.c.

◆ Rast_add_d_color_rule()

void Rast_add_d_color_rule ( const DCELL val1,
int  r1,
int  g1,
int  b1,
const DCELL val2,
int  r2,
int  g2,
int  b2,
struct Colors colors 
)

Adds the floating-point color rule (DCELL version)

See Rast_add_color_rule() for details.

Parameters
val1cell value
r1,g1,b1color value
val2cell value
r2,g2,b2color value
[in,out]colorspointer to color table structure

Definition at line 38 of file color_rule.c.

◆ Rast_add_f_color_rule()

void Rast_add_f_color_rule ( const FCELL cat1,
int  r1,
int  g1,
int  b1,
const FCELL cat2,
int  r2,
int  g2,
int  b2,
struct Colors colors 
)

Adds the floating-point color rule (FCELL version)

See Rast_add_color_rule() for details.

Parameters
cat1cell value
r1,g1,b1color value
cat2cell value
r2,g2,b2color value
[in,out]colorspointer to color table structure

Definition at line 57 of file color_rule.c.

◆ Rast_add_histogram()

int Rast_add_histogram ( CELL  cat,
long  count,
struct Histogram histogram 
)

adds count to the histogram value for cat

adds count to the histogram value for cat

Parameters
catcategory
count
histogramstruct for histogram
Returns
0 if successful, 1 on fail

Definition at line 348 of file histogram.c.

References Histogram::Histogram_list::cat, Histogram::Histogram_list::count, count, Histogram::list, Histogram::num, and Rast_extend_histogram().

Referenced by Rast_make_histogram_cs().

◆ Rast_add_modular_c_color_rule()

int Rast_add_modular_c_color_rule ( const CELL val1,
int  r1,
int  g1,
int  b1,
const CELL val2,
int  r2,
int  g2,
int  b2,
struct Colors colors 
)

Add modular integer color rule (CELL version)

Parameters
val1cell value
r1,g1,b1color value
val2cell value
r2,g2,b2color value
[in,out]colorspointer to color table structure
Returns
-1 on failure
1 on success

Definition at line 184 of file color_rule.c.

◆ Rast_add_modular_color_rule()

int Rast_add_modular_color_rule ( const void *  val1,
int  r1,
int  g1,
int  b1,
const void *  val2,
int  r2,
int  g2,
int  b2,
struct Colors colors,
RASTER_MAP_TYPE  data_type 
)

Add modular color rule.

Todo:
Question: shouldn't this function call G_add_modular_<data_type>_raster_color_rule() instead?
Parameters
val1cell value
r1,g1,b1color value
val2cell value
r2,g2,b2color value
[in,out]colorspointer to color table structure
data_typeraster data type
Returns
-1 on failure
1 on success

Definition at line 218 of file color_rule.c.

◆ Rast_add_modular_d_color_rule()

int Rast_add_modular_d_color_rule ( const DCELL val1,
int  r1,
int  g1,
int  b1,
const DCELL val2,
int  r2,
int  g2,
int  b2,
struct Colors colors 
)

Add modular floating-point color rule (DCELL version)

Parameters
val1cell value
r1,g1,b1color value
val2cell value
r2,g2,b2color value
[in,out]colorspointer to color table structure
Returns
-1 on failure
1 on success

Definition at line 124 of file color_rule.c.

◆ Rast_add_modular_f_color_rule()

int Rast_add_modular_f_color_rule ( const FCELL val1,
int  r1,
int  g1,
int  b1,
const FCELL val2,
int  r2,
int  g2,
int  b2,
struct Colors colors 
)

Add modular floating-point color rule (FCELL version)

Parameters
val1cell value
r1,g1,b1color value
val2cell value
r2,g2,b2color value
[in,out]colorspointer to color table structure
Returns
-1 on failure
1 on success

Definition at line 154 of file color_rule.c.

◆ Rast_align_window()

void Rast_align_window ( struct Cell_head window,
const struct Cell_head ref 
)

Align two regions.

Modifies the input window to align to ref region. The resolutions in window are set to match those in ref and the window edges (north, south, east, west) are modified to align with the grid of the ref region.

The window may be enlarged if necessary to achieve the alignment. The north is rounded northward, the south southward, the east eastward and the west westward. Lon-lon constraints are taken into consideration to make sure that the north doesn't go above 90 degrees (for lat/lon) or that the east does "wrap" past the west, etc.

Parameters
[in,out]windowpointer to Cell_head to be modified
refpointer to Cell_head
Returns
NULL on success

Definition at line 41 of file align_window.c.

◆ Rast_allocate_buf()

void* Rast_allocate_buf ( RASTER_MAP_TYPE  data_type)

Allocate memory for a raster map of given type.

Allocate an array of CELL, FCELL, or DCELL (depending on data_type) based on the number of columns in the current region.

Parameters
data_typeraster type (CELL, FCELL, DCELL)
Returns
pointer to allocated buffer

Definition at line 54 of file alloc_cell.c.

References G_calloc, Rast_cell_size(), and Rast_window_cols().

◆ Rast_allocate_c_buf()

CELL* Rast_allocate_c_buf ( void  )

Allocate memory for a CELL type raster map.

Allocate an array of CELL based on the number of columns in the current region.

This routine allocates a buffer of type CELL just large enough to hold one row of raster data based on the number of columns in the active region.

CELL *cell;
CELL * Rast_allocate_c_buf(void)
Allocate memory for a CELL type raster map.
Definition: alloc_cell.c:81
int CELL
Definition: gis.h:625

If larger buffers are required, the routine G_malloc() can be used. The routine is generally used with each open cell file.

Prints error message and calls exit() on error.

Returns
pointer to allocated buffer

Definition at line 81 of file alloc_cell.c.

References G_calloc, and Rast_window_cols().

Referenced by IL_create_bitmask(), and open_band_files().

◆ Rast_allocate_c_input_buf()

CELL* Rast_allocate_c_input_buf ( void  )

Definition at line 161 of file alloc_cell.c.

References G_calloc, and Rast_input_window_cols().

◆ Rast_allocate_c_output_buf()

CELL* Rast_allocate_c_output_buf ( void  )

Definition at line 186 of file alloc_cell.c.

References G_calloc, and Rast_output_window_cols().

◆ Rast_allocate_d_buf()

DCELL* Rast_allocate_d_buf ( void  )

Allocates memory for a raster map of type DCELL.

Allocate an array of DCELL based on the number of columns in the current region.

Returns
pointer to allocated buffer

Definition at line 107 of file alloc_cell.c.

References G_calloc, and Rast_window_cols().

◆ Rast_allocate_d_input_buf()

DCELL* Rast_allocate_d_input_buf ( void  )

Definition at line 171 of file alloc_cell.c.

References G_calloc, and Rast_input_window_cols().

◆ Rast_allocate_d_output_buf()

DCELL* Rast_allocate_d_output_buf ( void  )

Definition at line 196 of file alloc_cell.c.

References G_calloc, and Rast_output_window_cols().

◆ Rast_allocate_f_buf()

FCELL* Rast_allocate_f_buf ( void  )

Allocates memory for a raster map of type FCELL.

Allocate an array of FCELL based on the number of columns in the current region.

Returns
pointer to allocated buffer

Definition at line 94 of file alloc_cell.c.

References G_calloc, and Rast_window_cols().

◆ Rast_allocate_f_input_buf()

FCELL* Rast_allocate_f_input_buf ( void  )

Definition at line 166 of file alloc_cell.c.

References G_calloc, and Rast_input_window_cols().

◆ Rast_allocate_f_output_buf()

FCELL* Rast_allocate_f_output_buf ( void  )

Definition at line 191 of file alloc_cell.c.

References G_calloc, and Rast_output_window_cols().

◆ Rast_allocate_input_buf()

void* Rast_allocate_input_buf ( RASTER_MAP_TYPE  data_type)

Definition at line 156 of file alloc_cell.c.

References G_calloc, Rast_cell_size(), and Rast_input_window_cols().

Referenced by Rast_get_vrt_row().

◆ Rast_allocate_null_buf()

char* Rast_allocate_null_buf ( void  )

Allocates memory for a null buffer.

Allocate an array of char based on the number of columns in the current region.

Returns
pointer to allocated buffer

Definition at line 120 of file alloc_cell.c.

References G_calloc, and Rast_window_cols().

◆ Rast_allocate_null_input_buf()

char* Rast_allocate_null_input_buf ( void  )

Definition at line 176 of file alloc_cell.c.

References G_calloc, and Rast_input_window_cols().

◆ Rast_allocate_null_output_buf()

char* Rast_allocate_null_output_buf ( void  )

Definition at line 201 of file alloc_cell.c.

References G_calloc, and Rast_output_window_cols().

◆ Rast_allocate_output_buf()

void* Rast_allocate_output_buf ( RASTER_MAP_TYPE  data_type)

Definition at line 181 of file alloc_cell.c.

References G_calloc, Rast_cell_size(), and Rast_output_window_cols().

◆ Rast_append_format_history()

void Rast_append_format_history ( struct History ,
const char *  ,
  ... 
)

◆ Rast_append_history()

void Rast_append_history ( struct History hist,
const char *  str 
)

Append a string to a History structure.

Parameters
histpointer to History structure which holds history info
strstring to append
Returns
void

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

References G_realloc, G_store(), History::lines, and History::nlines.

Referenced by Rast__read_history(), and Rast_command_history().

◆ Rast_cell_size()

size_t Rast_cell_size ( RASTER_MAP_TYPE  data_type)

Returns size of a raster cell in bytes.

  • If data_type is CELL_TYPE, returns sizeof(CELL)
  • If data_type is FCELL_TYPE, returns sizeof(FCELL)
  • If data_type is DCELL_TYPE, returns sizeof(DCELL)
Parameters
data_typeraster type (CELL, FCELL, DCELL)
Returns
raster type size

Definition at line 38 of file alloc_cell.c.

Referenced by f_median(), f_nmedian(), Rast__set_null_value(), Rast_allocate_buf(), Rast_allocate_input_buf(), Rast_allocate_output_buf(), Rast_get_vrt_row(), Rast_raster_cpy(), Rast_row_update_fp_range(), Rast_zero_buf(), Rast_zero_input_buf(), and Rast_zero_output_buf().

◆ Rast_cell_stats_histo_eq()

int Rast_cell_stats_histo_eq ( struct Cell_stats statf,
CELL  min1,
CELL  max1,
CELL  min2,
CELL  max2,
int  zero,
void(*)(CELL, CELL, CELL func 
)

Definition at line 4 of file cellstats_eq.c.

◆ Rast_clear_history()

void void Rast_clear_history ( struct History hist)

Definition at line 307 of file raster/history.c.

References G_free(), History::lines, History::nlines, and NULL.

Referenced by Rast_free_history().

◆ Rast_close()

void Rast_close ( int  fd)

Close a raster map.

The raster map opened on file descriptor fd is closed. Memory allocated for raster processing is freed. If open for writing, skeletal support files for the new raster map are created as well.

Note: If a module wants to explicitly write support files (e.g., a specific color table) for a raster map it creates, it must do so after the raster map is closed. Otherwise the close will overwrite the support files. See Raster Map Layer Support Routines for routines which write raster support files.

If the map is a new floating point, move the .tmp file into the fcell element, create an empty file in the cell directory; write the floating-point range file; write a default quantization file quantization file is set here to round fp numbers (this is a default for now). create an empty category file, with max cat = max value (for backwards compatibility). Move the .tmp NULL-value bitmap file to the cell_misc directory.

Parameters
fdfile descriptor
Returns
void

Definition at line 99 of file raster/close.c.

References _, R__::fileinfo, R__::fileinfo_count, G_fatal_error(), fileinfo::open_mode, and OPEN_OLD.

Referenced by close_band_files(), IL_create_bitmask(), and Rast_suppress_masking().

◆ Rast_close_gdal_link()

void Rast_close_gdal_link ( struct GDAL_link gdal)

Close existing GDAL link.

Parameters
gdalpointer to GDAL_link to be closed

Definition at line 397 of file gdal.c.

References GDAL_link::data, GDAL_link::filename, and G_free().

◆ Rast_close_gdal_write_link()

int Rast_close_gdal_write_link ( struct GDAL_link gdal)

Close existing GDAL link and write out data.

Parameters
gdalpointer to GDAL_link to be closed
Returns
1 on success
-1 on failure

Definition at line 414 of file gdal.c.

References GDAL_link::data, G_strcasecmp(), and st.

◆ Rast_close_vrt()

void Rast_close_vrt ( struct R_vrt vrt)

◆ Rast_col_to_easting()

double Rast_col_to_easting ( double  col,
const struct Cell_head window 
)

Column to easting.

Converts a col relative to a window to an easting.

Note: col is a double:

  • col+0.0 will return the easting for the western edge of the column.
  • col+0.5 will return the easting for the center of the column.
  • col+1.0 will return the easting for the eastern edge of the column.
Parameters
colcolumn number
[in]windowpointer to Cell_head
Returns
east coordinate

Definition at line 269 of file raster/window.c.

◆ Rast_colors_count()

int Rast_colors_count ( const struct Colors colors)

Get both modular and fixed rules count.

Parameters
colorspointer to color table structure
Returns
number of rules in color table

Definition at line 24 of file color_rule_get.c.

◆ Rast_command_history()

int Rast_command_history ( struct History hist)

Save command line to raster history structure.

This routine takes an existing (run Rast_short_history first() history structure and adds the command line to the end of the comments array, as cleaned & expanded by the parser.

  • First version had for loops of [i][j] character assignments and ending nulls, but using the string libraries is cleaner and less bug prone.
  • Second version had white space detection, intelligent wrapping, and indentation of continued lines, but this proved a pain in the neck for things like r.patch which can have long strings without any parser-acceptable breaks.
  • This is MK-III, simplified, but that's good: it's cut & paste-able.

Note: use Rast_write_history() to write the structure.

Sample Usage:

struct History history;
Rast_short_history(rasterfile, "raster", &history);
Rast_write_history(rasterfile, &history);
void Rast_write_history(const char *, struct History *)
Write raster history file.
void Rast_short_history(const char *, const char *, struct History *)
Initialize history structure.
int Rast_command_history(struct History *)
Save command line to raster history structure.
Raster history info (metadata)
Definition: raster.h:172
Parameters
histpointer to History structure which holds history info
Returns
0 on success
1 on failure (history file full, no change)
2 on failure (history file full, added as much as we could)

Definition at line 274 of file raster/history.c.

References G_free(), G_recreate_command(), History::nlines, and Rast_append_history().

◆ Rast_construct_default_range()

void Rast_construct_default_range ( struct Range range)

Construct default range.

Sets the integer range to [1,255]

Parameters
[out]rpointer to Range structure which holds range info

Definition at line 45 of file raster/range.c.

References DEFAULT_CELL_MAX, DEFAULT_CELL_MIN, and Rast_update_range().

◆ Rast_copy_cats()

void Rast_copy_cats ( struct Categories pcats_to,
const struct Categories pcats_from 
)

Copy raster categories.

Allocates NEW space for quant rules and labels n pcats_to and copies all info from pcats_from cats to pcats_to cats.

Parameters
pcats_topointer to destination Categories structure
pcats_frompointer to source Categories structure

Definition at line 1248 of file raster/cats.c.

References Categories::ncats, Rast_get_ith_d_cat(), Rast_init_cats(), Rast_set_d_cat(), and Categories::title.

Referenced by Rast_sort_cats().

◆ Rast_create_gdal_link()

struct GDAL_link* Rast_create_gdal_link ( const char *  name,
RASTER_MAP_TYPE  map_type 
)

Create GDAL settings for given raster map.

Parameters
namemap name
map_typemap type (CELL, FCELL, DCELL)
Returns
pointer to allocated GDAL_link structure
NULL on error

Definition at line 240 of file gdal.c.

References driver, G_is_initialized(), GPATH_MAX, Rast__init_window(), Rast_init_gdal(), and st.

◆ Rast_easting_to_col()

double Rast_easting_to_col ( double  east,
const struct Cell_head window 
)

Easting to column.

Converts east relative to a window to a column.

Note: The result is a double. Casting it to an int will give the column number.

Parameters
easteast coordinate
windowpointer to Cell_head
Returns
column number

Definition at line 226 of file raster/window.c.

◆ Rast_extend_histogram()

void Rast_extend_histogram ( CELL  cat,
long  count,
struct Histogram histogram 
)

Extends histogram struct to accommodate a new value.

Parameters
catcategory
count
histogramstruct for histogram
Returns

Definition at line 396 of file histogram.c.

References Histogram::Histogram_list::cat, Histogram::Histogram_list::count, count, G_realloc, Histogram::list, LIST, and Histogram::num.

Referenced by Rast_add_histogram(), Rast_read_histogram(), and Rast_set_histogram().

◆ Rast_find_cell_stat()

int Rast_find_cell_stat ( CELL  cat,
long *  count,
const struct Cell_stats s 
)

Random query of cell stats.

This routine allows a random query of the Cell_stats structure. The count associated with the raster value cat is set. The routine returns 1 if cat was found in the structure, 0 otherwise.

Allow finding the count for the NULL-value.

Parameters
catraster value
[out]countcount
spointer to Cell_stats structure which holds cell stats info
Returns
1 if found
0 if not found

Definition at line 188 of file cell_stats.c.

◆ Rast_format_history()

void Rast_format_history ( struct History ,
int  ,
const char *  ,
  ... 
)

◆ Rast_fpreclass_add_rule()

void Rast_fpreclass_add_rule ( struct FPReclass r,
DCELL  dLow,
DCELL  dHigh,
DCELL  rLow,
DCELL  rHigh 
)

Definition at line 451 of file fpreclass.c.

◆ Rast_fpreclass_clear()

void Rast_fpreclass_clear ( struct FPReclass r)

Definition at line 257 of file fpreclass.c.

References r.

Referenced by Rast_fpreclass_reset().

◆ Rast_fpreclass_get_cell_value()

◆ Rast_fpreclass_get_ith_rule()

void Rast_fpreclass_get_ith_rule ( const struct FPReclass r,
int  i,
DCELL dLow,
DCELL dHigh,
DCELL rLow,
DCELL rHigh 
)

Definition at line 371 of file fpreclass.c.

References r.

◆ Rast_fpreclass_get_limits()

int Rast_fpreclass_get_limits ( const struct FPReclass r,
DCELL dMin,
DCELL dMax,
DCELL rMin,
DCELL rMax 
)

Definition at line 332 of file fpreclass.c.

References DEFAULT_MAX, DEFAULT_MIN, NO_DEFAULT_RULE, NO_EXPLICIT_RULE, and r.

◆ Rast_fpreclass_get_neg_infinite_rule()

int Rast_fpreclass_get_neg_infinite_rule ( const struct FPReclass r,
DCELL dLeft,
DCELL c 
)

Definition at line 412 of file fpreclass.c.

◆ Rast_fpreclass_get_pos_infinite_rule()

int Rast_fpreclass_get_pos_infinite_rule ( const struct FPReclass r,
DCELL dRight,
DCELL c 
)

Definition at line 437 of file fpreclass.c.

◆ Rast_fpreclass_init()

void Rast_fpreclass_init ( struct FPReclass r)

Definition at line 279 of file fpreclass.c.

References r, and Rast_fpreclass_reset().

◆ Rast_fpreclass_nof_rules()

int Rast_fpreclass_nof_rules ( const struct FPReclass r)

Definition at line 364 of file fpreclass.c.

References r.

◆ Rast_fpreclass_perform_dd()

void Rast_fpreclass_perform_dd ( const struct FPReclass r,
const DCELL dcell,
DCELL cell,
int  n 
)

◆ Rast_fpreclass_perform_df()

void Rast_fpreclass_perform_df ( const struct FPReclass r,
const DCELL dcell,
FCELL cell,
int  n 
)

◆ Rast_fpreclass_perform_di()

void Rast_fpreclass_perform_di ( const struct FPReclass r,
const DCELL dcell,
CELL cell,
int  n 
)

◆ Rast_fpreclass_perform_fd()

void Rast_fpreclass_perform_fd ( const struct FPReclass r,
const FCELL fcell,
DCELL cell,
int  n 
)

◆ Rast_fpreclass_perform_ff()

void Rast_fpreclass_perform_ff ( const struct FPReclass r,
const FCELL fcell,
FCELL cell,
int  n 
)

◆ Rast_fpreclass_perform_fi()

void Rast_fpreclass_perform_fi ( const struct FPReclass r,
const FCELL fcell,
CELL cell,
int  n 
)

◆ Rast_fpreclass_perform_id()

void Rast_fpreclass_perform_id ( const struct FPReclass r,
const CELL icell,
DCELL cell,
int  n 
)

◆ Rast_fpreclass_perform_if()

void Rast_fpreclass_perform_if ( const struct FPReclass r,
const CELL icell,
FCELL cell,
int  n 
)

◆ Rast_fpreclass_perform_ii()

void Rast_fpreclass_perform_ii ( const struct FPReclass r,
const CELL icell,
CELL cell,
int  n 
)

◆ Rast_fpreclass_reset()

void Rast_fpreclass_reset ( struct FPReclass r)

Definition at line 267 of file fpreclass.c.

References G_free(), r, and Rast_fpreclass_clear().

Referenced by Rast_fpreclass_init().

◆ Rast_fpreclass_reverse_rule_order()

void Rast_fpreclass_reverse_rule_order ( struct FPReclass r)

Definition at line 482 of file fpreclass.c.

◆ Rast_fpreclass_set_domain()

void Rast_fpreclass_set_domain ( struct FPReclass r,
DCELL  dLow,
DCELL  dHigh 
)

Definition at line 287 of file fpreclass.c.

References r.

◆ Rast_fpreclass_set_neg_infinite_rule()

void Rast_fpreclass_set_neg_infinite_rule ( struct FPReclass r,
DCELL  dLeft,
DCELL  c 
)

Definition at line 401 of file fpreclass.c.

◆ Rast_fpreclass_set_pos_infinite_rule()

void Rast_fpreclass_set_pos_infinite_rule ( struct FPReclass r,
DCELL  dRight,
DCELL  c 
)

Definition at line 426 of file fpreclass.c.

◆ Rast_fpreclass_set_range()

void Rast_fpreclass_set_range ( struct FPReclass r,
DCELL  low,
DCELL  high 
)

Definition at line 296 of file fpreclass.c.

References r.

◆ Rast_free_cats()

void Rast_free_cats ( struct Categories pcats)

Free category structure memory.

Todo:
To be removed, replaced by Rast_free_cats().

Frees memory allocated by Rast_read_cats(), Rast_init_cats() and Rast_set_c_cat().

Parameters
pcatspointer to Categories structure

Definition at line 1213 of file raster/cats.c.

References Categories::fmt, G_free(), Categories::labels, Categories::marks, Categories::nalloc, Categories::ncats, NULL, Categories::q, Rast_quant_free(), and Categories::title.

◆ Rast_free_cell_stats()

void Rast_free_cell_stats ( struct Cell_stats s)

Free cell stats structure.

The memory associated with structure s is freed. This routine may be called any time after calling Rast_init_cell_stats().

Parameters
spointer to Cell_stats structure

Definition at line 382 of file cell_stats.c.

◆ Rast_free_colors()

void Rast_free_colors ( struct Colors colors)

Free color structure memory.

The dynamically allocated memory associated with the colors structure is freed.

Note: This routine may be used after Rast_read_colors() as well as after Rast_init_colors().

Parameters
colorspointer to Colors structure

Definition at line 30 of file color_free.c.

Referenced by Gvl_unload_colors_data().

◆ Rast_free_histogram()

void Rast_free_histogram ( struct Histogram histogram)

Frees memory allocated for the histogram.

frees the memory allocated for the histogram

Parameters
histogramstruct for histogram
Returns

Definition at line 202 of file histogram.c.

References G_free(), Histogram::list, NULL, and Histogram::num.

◆ Rast_free_history()

void Rast_free_history ( struct History hist)

Definition at line 321 of file raster/history.c.

References History::fields, G_free(), HIST_NUM_FIELDS, NULL, and Rast_clear_history().

◆ Rast_free_reclass()

void Rast_free_reclass ( struct Reclass reclass)

Free Reclass structure.

Parameters
reclasspointer to Reclass structure

Definition at line 183 of file reclass.c.

References G_free(), Reclass::mapset, Reclass::name, NULL, Reclass::num, RECLASS_TABLE, Reclass::table, and Reclass::type.

◆ Rast_get_c_cat()

char* Rast_get_c_cat ( CELL rast,
struct Categories pcats 
)

Get a raster category label (CELL)

This routine looks up category rast in the pcats structure and returns a pointer to a string which is the label for the category. A legal pointer is always returned. If the category does not exist in pcats, then a pointer to the empty string "" is returned.

Warning: The pointer that is returned points to a hidden static buffer. Successive calls to Rast_get_c_cat() overwrite this buffer.

Parameters
rastcell value
pcatspointer to Categories structure
Returns
pointer to category label
"" if category is not found

Definition at line 321 of file raster/cats.c.

References CELL_TYPE, and Rast_get_cat().

◆ Rast_get_c_color()

int Rast_get_c_color ( const CELL rast,
int *  red,
int *  grn,
int *  blu,
struct Colors colors 
)

Gets color from raster map (CELL)

Looks up the rgb colors for rast in the color table colors.

Parameters
rastraster cell value
[out]redred value
[out]grngreen value
[out]blublue value
colorspointer to Colors structure which holds color info
Returns
1 if color is set
0 if color is not set

Definition at line 67 of file color_get.c.

◆ Rast_get_c_color_range()

void Rast_get_c_color_range ( CELL min,
CELL max,
const struct Colors colors 
)

Get color range values (CELL)

Returns min and max category in the range or huge numbers if the color table is defined on floating cell values and not on categories.

Parameters
[out]min,maxminimum and maximum value
colorspointer to Colors structure which holds color info

Definition at line 64 of file color_range.c.

◆ 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 798 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 698 of file raster/get_row.c.

References CELL_TYPE, and Rast_get_row_nomask().

Referenced by read_band_row().

◆ 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_cat()

char* Rast_get_cat ( void *  rast,
struct Categories pcats,
RASTER_MAP_TYPE  data_type 
)

Get a raster category label.

This routine looks up category rast in the pcats structure and returns a pointer to a string which is the label for the category. A legal pointer is always returned. If the category does not exist in pcats, then a pointer to the empty string "" is returned.

Warning: The pointer that is returned points to a hidden static buffer. Successive calls to Rast_get_c_cat() overwrite this buffer.

Parameters
rastcell value
pcatspointer to Categories structure
data_typemap type (CELL, FCELL, DCELL)
Returns
pointer to category label
"" if category is not found

Definition at line 394 of file raster/cats.c.

References l.

Referenced by Rast_get_c_cat(), Rast_get_d_cat(), and Rast_get_f_cat().

◆ Rast_get_cats_title()

char* Rast_get_cats_title ( const struct Categories pcats)

Get title from category structure struct.

Todo:
Remove from GIS Library, replace by Rast_get_c_cats_title().

Map layers store a one-line title in the category structure as well. This routine returns a pointer to the title contained in the cats structure. A legal pointer is always returned. If the map layer does not have a title, then a pointer to the empty string "" is returned.

Parameters
pcatspointer to Categories structure
Returns
title
"" if missing

Definition at line 297 of file raster/cats.c.

References Categories::title.

◆ Rast_get_cell_format()

int Rast_get_cell_format ( CELL  v)

Get cell value format.

Parameters
vcell
Returns
cell format

Definition at line 480 of file raster/open.c.

◆ Rast_get_cell_title()

char* Rast_get_cell_title ( const char *  name,
const char *  mapset 
)

get raster map title

If only the map layer title is needed, it is not necessary to read the entire category file into memory. This routine gets the title for raster map name in mapset directly from the category file, and returns a pointer to the title. A legal pointer is always returned. If the map layer does not have a title, then a pointer to the empty string "" is returned.

Parameters
name
mapset
Returns
char *

Definition at line 25 of file cell_title.c.

References G_fopen_old(), G_getl(), G_store(), G_strip(), and name.

◆ Rast_get_cellhd()

void Rast_get_cellhd ( const char *  name,
const char *  mapset,
struct Cell_head cellhd 
)

Read the raster header.

The raster header for the raster map name in the specified mapset is read into the cellhd structure. If there is an error reading the raster header file, G_fatal_error() is called.

Cell header files may contain either grid cell header information or reclass information. If it is a reclass file, it will specify the map and mapset names of the actual grid cell file being reclassed. Rast_get_cellhd(), upon reading reclass information will go read the cell header information for the referenced file. Only one reference is allowed.

Parameters
namename of map
mapsetmapset that map belongs to
[out]cellhdstructure to hold cell header info
Returns
void

Definition at line 41 of file get_cellhd.c.

References _, G__read_Cell_head(), G_fatal_error(), G_find_raster(), G_fopen_old(), GMAPSET_MAX, GNAME_MAX, name, and Rast_is_reclass().

Referenced by Rast__check_for_auto_masking(), Rast__open_old(), and Rast_get_vrt().

◆ Rast_get_color()

int Rast_get_color ( const void *  rast,
int *  red,
int *  grn,
int *  blu,
struct Colors colors,
RASTER_MAP_TYPE  map_type 
)

Gets color from raster map.

Looks up the rgb colors for rast in the color table colors.

The red, green, and blue intensities for the color associated with category n are extracted from the colors structure. The intensities will be in the range 0 -

  1. Also works for null cells.
Parameters
rastraster cell value
[out]redred value
[out]grngreen value
[out]blublue value
colorspointer to Colors structure which holds color info
map_typemap type (CELL, FCELL, DCELL)
Returns
1 if color is set
0 if color is not set

Definition at line 38 of file color_get.c.

◆ Rast_get_d_cat()

char* Rast_get_d_cat ( DCELL rast,
struct Categories pcats 
)

Get a raster category label (DCELL)

This routine looks up category rast in the pcats structure and returns a pointer to a string which is the label for the category. A legal pointer is always returned. If the category does not exist in pcats, then a pointer to the empty string "" is returned.

Warning: The pointer that is returned points to a hidden static buffer. Successive calls to Rast_get_c_cat() overwrite this buffer.

Parameters
rastcell value
pcatspointer to Categories structure
Returns
pointer to category label
"" if category is not found

Definition at line 369 of file raster/cats.c.

References DCELL_TYPE, and Rast_get_cat().

◆ Rast_get_d_color()

int Rast_get_d_color ( const DCELL rast,
int *  red,
int *  grn,
int *  blu,
struct Colors colors 
)

Gets color from raster map (DCELL)

Looks up the rgb colors for rast in the color table colors.

Parameters
rastraster cell value
[out]redred value
[out]grngreen value
[out]blublue value
colorspointer to Colors structure which holds color info
Returns
1 if color is set
0 if color is not set

Definition at line 109 of file color_get.c.

◆ Rast_get_d_color_range()

void Rast_get_d_color_range ( DCELL min,
DCELL max,
const struct Colors colors 
)

Get color range values (DCELL)

Returns min and max category in the range or huge numbers if the color table is defined on floating cell values and not on categories.

Parameters
[out]min,maxminimum and maximum value
colorspointer to Colors structure which holds color info

Definition at line 86 of file color_range.c.

◆ 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 835 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 730 of file raster/get_row.c.

References DCELL_TYPE, and Rast_get_row_nomask().

◆ 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_default_color()

void Rast_get_default_color ( int *  red,
int *  grn,
int *  blu,
const struct Colors colors 
)

Gets default color.

Puts the red, green, and blue components of the "default" color into red, grn, and blu.

Parameters
[out]redred value
[out]grngreen value
[out]blublue value
colorspointer to Colors structure which holds color info

Definition at line 154 of file color_get.c.

◆ Rast_get_f_cat()

char* Rast_get_f_cat ( FCELL rast,
struct Categories pcats 
)

Get a raster category label (FCELL)

This routine looks up category rast in the pcats structure and returns a pointer to a string which is the label for the category. A legal pointer is always returned. If the category does not exist in pcats, then a pointer to the empty string "" is returned.

Warning: The pointer that is returned points to a hidden static buffer. Successive calls to Rast_get_c_cat() overwrite this buffer.

Parameters
rastcell value
pcatspointer to Categories structure
Returns
pointer to category label
"" if category is not found

Definition at line 345 of file raster/cats.c.

References FCELL_TYPE, and Rast_get_cat().

◆ Rast_get_f_color()

int Rast_get_f_color ( const FCELL rast,
int *  red,
int *  grn,
int *  blu,
struct Colors colors 
)

Gets color from raster map (FCELL)

Looks up the rgb colors for rast in the color table colors.

Parameters
rastraster cell value
[out]redred value
[out]grngreen value
[out]blublue value
colorspointer to Colors structure which holds color info
Returns
1 if color is set
0 if color is not set

Definition at line 88 of file color_get.c.

Referenced by Gvl_get_color_for_value().

◆ 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 818 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 714 of file raster/get_row.c.

References FCELL_TYPE, and Rast_get_row_nomask().

◆ 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_get_fp_color_rule()

int Rast_get_fp_color_rule ( DCELL val1,
unsigned char *  r1,
unsigned char *  g1,
unsigned char *  b1,
DCELL val2,
unsigned char *  r2,
unsigned char *  g2,
unsigned char *  b2,
const struct Colors colors,
int  rule 
)

Get color rule from both modular and fixed rules.

Rules are returned in the order as stored in the table (i.e. unexpected, high values first)

Parameters
val1color value
[out]r1,g1,b1color value
val2color value
[out]r2,g2,b2color value
colorspointer to color table structure
rulerule index from 0 to G_color_count()-1
Returns
0 success
1 index out of range

Definition at line 66 of file color_rule_get.c.

◆ Rast_get_fp_range_min_max()

void Rast_get_fp_range_min_max ( const struct FPRange range,
DCELL min,
DCELL max 
)

Get minimum and maximum value from fp range.

Extract the min/max from the range structure range. If the range structure has no defined min/max (first!=0) there will not be a valid range. In this case the min and max returned must be the NULL-value.

Parameters
rangepointer to FPRange which holds fp range info
[out]minminimum value
[out]maxmaximum value

Definition at line 768 of file raster/range.c.

References FPRange::first_time, FPRange::max, max, FPRange::min, min, Rast_is_d_null_value, and Rast_set_d_null_value().

Referenced by Rast3d_range_min_max(), Rast_quantize_fp_map(), and Rast_read_range().

◆ Rast_get_gdal_link()

struct GDAL_link* Rast_get_gdal_link ( const char *  name,
const char *  mapset 
)

Get GDAL link settings for given raster map.

Parameters
namemap name
mapsetname of mapset
Returns
pointer to GDAL_link structure
NULL if link not found

Definition at line 61 of file gdal.c.

Referenced by Rast__open_old().

◆ Rast_get_histogram_cat()

CELL Rast_get_histogram_cat ( int  n,
const struct Histogram histogram 
)

Returns cat for the nth element in the histogram.

Returns cat for the nth element in the histogram

Parameters
histogramstruct for histogram
Returns
CELL

Definition at line 171 of file histogram.c.

References Histogram::Histogram_list::cat, Histogram::list, and Histogram::num.

◆ Rast_get_histogram_count()

long Rast_get_histogram_count ( int  n,
const struct Histogram histogram 
)

Returns count for the nth element in the histogram.

Returns count for the nth element in the histogram

Parameters
nnth element
histogramstruct for histogram
Returns
count

Definition at line 187 of file histogram.c.

References Histogram::Histogram_list::count, Histogram::list, and Histogram::num.

◆ Rast_get_histogram_num()

int Rast_get_histogram_num ( const struct Histogram histogram)

Sorts the histogram in ascending order by counts then category.

Sorts the histogram in ascending order by counts then category. No combining is done.

Parameters
histogramstruct for histogram
Returns
1 if successful, -1 on fail

Definition at line 159 of file histogram.c.

References Histogram::num.

◆ Rast_get_history()

void const char* Rast_get_history ( struct History hist,
int  field 
)

Set the string of a specific history field.

Parameters
histpointer to History structure which holds history info
fieldnumber of a specific history field, should be accessed with macros (HIST_MAPID, ...)
Returns
string of the history field

Definition at line 178 of file raster/history.c.

References History::fields.

◆ Rast_get_input_window()

void Rast_get_input_window ( struct Cell_head window)

Read the current input window.

Parameters
windowpointer to Cell_head

Definition at line 45 of file raster/window.c.

◆ Rast_get_ith_c_cat()

char* Rast_get_ith_c_cat ( const struct Categories pcats,
int  i,
void *  rast1,
void *  rast2 
)

Get category description (CELL)

Returns i-th description and i-th data range from the list of category descriptions with corresponding data ranges. end points of data interval in rast1 and rast2.

Parameters
pcatspointer to Categories structure
iindex
rast1,rast2raster values (range)
Returns
"" on error
pointer to category description

Definition at line 1084 of file raster/cats.c.

References CELL_TYPE.

◆ Rast_get_ith_cat()

char* Rast_get_ith_cat ( const struct Categories pcats,
int  i,
void *  rast1,
void *  rast2,
RASTER_MAP_TYPE  data_type 
)

Get category description.

Returns i-th description and i-th data range from the list of category descriptions with corresponding data ranges. end points of data interval in rast1 and rast2.

Parameters
pcatspointer to Categories structure
iindex
rast1,rast2raster values (range)
data_typemap type
Returns
"" on error
pointer to category description

Definition at line 1112 of file raster/cats.c.

◆ Rast_get_ith_d_cat()

char* Rast_get_ith_d_cat ( const struct Categories pcats,
int  i,
DCELL rast1,
DCELL rast2 
)

Get category description (DCELL)

Returns i-th description and i-th data range from the list of category descriptions with corresponding data ranges. end points of data interval in rast1 and rast2.

Parameters
pcatspointer to Categories structure
iindex
rast1,rast2raster values (range)
Returns
"" on error
pointer to category description

Definition at line 1029 of file raster/cats.c.

References Categories::labels, Categories::ncats, Categories::q, Rast_quant_get_ith_rule(), and Rast_set_d_null_value().

Referenced by Rast3d_write_cats(), Rast_copy_cats(), Rast_get_next_marked_d_cat(), and Rast_set_d_cat().

◆ Rast_get_ith_f_cat()

char* Rast_get_ith_f_cat ( const struct Categories pcats,
int  i,
void *  rast1,
void *  rast2 
)

Get category description (FCELL)

Returns i-th description and i-th data range from the list of category descriptions with corresponding data ranges. end points of data interval in rast1 and rast2.

Parameters
pcatspointer to Categories structure
iindex
rast1,rast2raster values (range)
Returns
"" on error
pointer to category description

Definition at line 1057 of file raster/cats.c.

References FCELL_TYPE.

◆ Rast_get_map_type()

RASTER_MAP_TYPE Rast_get_map_type ( int  fd)

Determine raster type from descriptor.

Determines if the raster map is floating point or integer. Returns DCELL_TYPE for double maps, FCELL_TYPE for float maps, CELL_TYPE for integer maps, -1 if error has occurred

Parameters
fdfile descriptor
Returns
raster data type

Definition at line 932 of file raster/open.c.

References R__::fileinfo, and fileinfo::map_type.

◆ Rast_get_max_c_cat()

CELL Rast_get_max_c_cat ( const char *  name,
const char *  mapset 
)

Get the max category number.

Return the max category number of a raster map of type CELL.

Parameters
nameraster map name
mapsetmapset name
Returns
-1 on error
number of cats

Definition at line 171 of file raster/cats.c.

References max, min, name, Rast_get_range_min_max(), Rast_is_c_null_value, and Rast_read_range().

◆ Rast_get_next_marked_c_cat()

char* Rast_get_next_marked_c_cat ( struct Categories pcats,
CELL rast1,
CELL rast2,
long *  count 
)

Get next marked raster categories (CELL)

Parameters
pcatspointer to Categories structure
rast1,rast2cell values (raster range)
[out]countcount
Returns
NULL if not found
description if found

Definition at line 639 of file raster/cats.c.

References CELL_TYPE, count, and Rast_get_next_marked_cat().

◆ Rast_get_next_marked_cat()

char* Rast_get_next_marked_cat ( struct Categories pcats,
void *  rast1,
void *  rast2,
long *  count,
RASTER_MAP_TYPE  data_type 
)

Get next marked raster categories.

Parameters
pcatspointer to Categories structure
rast1,rast2cell values (raster range)
[out]countcount
data_typemap type
Returns
NULL if not found
description if found

Definition at line 672 of file raster/cats.c.

References count, Rast_get_next_marked_d_cat(), and Rast_set_d_value().

Referenced by Rast_get_next_marked_c_cat(), and Rast_get_next_marked_f_cat().

◆ Rast_get_next_marked_d_cat()

char* Rast_get_next_marked_d_cat ( struct Categories pcats,
DCELL rast1,
DCELL rast2,
long *  count 
)

Get next marked raster categories (DCELL)

Parameters
pcatspointer to Categories structure
rast1,rast2cell values (raster range)
[out]countcount
Returns
NULL if not found
description if found

Definition at line 599 of file raster/cats.c.

References count, G_debug(), Categories::last_marked_rule, Categories::marks, NULL, Categories::q, Rast_get_ith_d_cat(), and Rast_quant_nof_rules().

Referenced by Rast_get_next_marked_cat().

◆ Rast_get_next_marked_f_cat()

char* Rast_get_next_marked_f_cat ( struct Categories pcats,
FCELL rast1,
FCELL rast2,
long *  count 
)

Get next marked raster categories (FCELL)

Parameters
pcatspointer to Categories structure
rast1,rast2cell values (raster range)
[out]countcount
Returns
NULL if not found
description if found

Definition at line 655 of file raster/cats.c.

References count, FCELL_TYPE, and Rast_get_next_marked_cat().

◆ Rast_get_null_value_color()

void Rast_get_null_value_color ( int *  red,
int *  grn,
int *  blu,
const struct Colors colors 
)

Gets color for null value.

Puts the red, green, and blue components of colors for the NULL-value into red, grn, and blu.

Parameters
[out]redred value
[out]grngreen value
[out]blublue value
colorspointer to Colors structure which holds color info

Definition at line 126 of file color_get.c.

◆ 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 1097 of file raster/get_row.c.

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

◆ Rast_get_output_window()

void Rast_get_output_window ( struct Cell_head window)

Read the current output window.

Parameters
windowpointer to Cell_head

Definition at line 58 of file raster/window.c.

◆ Rast_get_range_min_max()

void Rast_get_range_min_max ( const struct Range range,
CELL min,
CELL max 
)

Get range min and max.

The minimum and maximum CELL values are extracted from the range structure.

If the range structure has no defined min/max (first!=0) there will not be a valid range. In this case the min and max returned must be the NULL-value.

Parameters
rangepointer to Range structure which holds range info
[out]minminimum value
[out]maxmaximum value

Definition at line 718 of file raster/range.c.

References Range::first_time, Range::max, max, Range::min, min, Rast_is_c_null_value, and Rast_set_c_null_value().

Referenced by Rast_get_max_c_cat().

◆ Rast_get_reclass()

int Rast_get_reclass ( const char *  name,
const char *  mapset,
struct Reclass reclass 
)

Get reclass.

Parameters
namemap name
mapsetmapset name
[out]reclasspointer to Reclass structure
Returns
-1 on error
type code

Definition at line 140 of file reclass.c.

Referenced by Rast__open_old().

◆ 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 774 of file raster/get_row.c.

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

◆ Rast_get_row_colors()

void Rast_get_row_colors ( int  fd,
int  row,
struct Colors colors,
unsigned char *  red,
unsigned char *  grn,
unsigned char *  blu,
unsigned char *  nul 
)

Reads a row of raster data and converts it to RGB.

Reads a row of raster data and converts it to red, green and blue components according to the colors parameter. This provides a convenient way to treat a raster layer as a color image without having to explicitly cater for each of CELL, FCELL and DCELL types.

Parameters
fdfield descriptor
rowrow number
colorspointer to Colors structure which holds color info
[out]redred value
[out]grngreen value
[out]blublue value
[out]nulnull value
Returns
void

Definition at line 39 of file get_row_colr.c.

◆ 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 682 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().

◆ Rast_get_sample()

DCELL Rast_get_sample ( int  fd,
const struct Cell_head window,
struct Categories cats,
double  north,
double  east,
int  usedesc,
INTERP_TYPE  itype 
)

Extract a cell value from raster map.

Extract a cell value from raster map at given northing and easting with a sampled 3x3 window using a specified interpolation method.

  • NEAREST neighbor interpolation
  • BILINEAR bilinear interpolation
  • CUBIC cubic interpolation
Parameters
fdfile descriptor
windowregion settings
catscategories
northnorthing position
easteasting position
usedescflag to scan category label
itypeinterpolation method
Returns
cell value at given position

Definition at line 49 of file sample.c.

◆ Rast_get_sample_bilinear()

DCELL Rast_get_sample_bilinear ( int  fd,
const struct Cell_head window,
struct Categories cats,
double  north,
double  east,
int  usedesc 
)

Extract a cell value from raster map (bilinear interpolation).

Extract a cell value from raster map at given northing and easting with a sampled 3x3 window using a bilinear interpolation.

Parameters
fdfile descriptor
windowregion settings
catscategories
northnorthing position
easteasting position
usedescflag to scan category label
Returns
cell value at given position

Definition at line 144 of file sample.c.

◆ Rast_get_sample_cubic()

DCELL Rast_get_sample_cubic ( int  fd,
const struct Cell_head window,
struct Categories cats,
double  north,
double  east,
int  usedesc 
)

Extract a cell value from raster map (cubic interpolation).

Extract a cell value from raster map at given northing and easting with a sampled 3x3 window using a cubic interpolation.

Parameters
fdfile descriptor
windowregion settings
catscategories
northnorthing position
easteasting position
usedescflag to scan category label
Returns
cell value at given position

Definition at line 232 of file sample.c.

◆ Rast_get_sample_nearest()

DCELL Rast_get_sample_nearest ( int  fd,
const struct Cell_head window,
struct Categories cats,
double  north,
double  east,
int  usedesc 
)

Extract a cell value from raster map (neighbor interpolation)

Extract a cell value from raster map at given northing and easting with a sampled 3x3 window using a neighbor interpolation.

Parameters
fdfile descriptor
windowregion settings
catscategories
northnorthing position
easteasting position
usedescflag to scan category label
Returns
cell value at given position

Definition at line 89 of file sample.c.

◆ Rast_get_semantic_label_or_name()

char* Rast_get_semantic_label_or_name ( const char *  name,
const char *  mapset 
)

Get a raster map semantic label or fall back to its name.

Use this function if a semantic label is needed but not mandated.

Parameters
nameraster map name
mapsetmapset name
Returns
string representing semantic label or map name

Definition at line 110 of file raster_metadata.c.

References G_store(), name, and Rast_read_semantic_label().

Referenced by I_iclass_init_signatures(), I_sort_signatures_by_semantic_label(), and I_SortSigSetBySemanticLabel().

◆ Rast_get_stats_for_null_value()

void Rast_get_stats_for_null_value ( long *  count,
const struct Cell_stats s 
)

Get number of null values.

Get a number of null values from stats structure.

Note: when reporting values which appear in a map using Rast_next_cell_stats(), to get stats for null, call Rast_get_stats_for_null_value() first, since Rast_next_cell_stats() does not report stats for null.

Parameters
countcount
spointer to Cell_stats structure which holds cell stats info

Definition at line 369 of file cell_stats.c.

◆ Rast_get_vrt()

◆ Rast_get_vrt_row()

◆ Rast_get_window()

void Rast_get_window ( struct Cell_head window)

Read the current window.

Parameters
windowpointer to Cell_head

Definition at line 26 of file raster/window.c.

◆ Rast_histogram_eq()

void Rast_histogram_eq ( const struct Histogram histo,
unsigned char **  map,
CELL min,
CELL max 
)

Definition at line 14 of file histo_eq.c.

References count, and x.

◆ Rast_histogram_eq_colors()

void Rast_histogram_eq_colors ( struct Colors dst,
struct Colors src,
struct Cell_stats statf 
)

Make histogram-stretched version of existing color table.

Generates a histogram contrast-stretched color table that goes from the histogram information in the Cell_stats structure statf. (See Raster Histograms).

Parameters
[out]dststruct to hold new colors
srcstruct containing original colors
statfcell stats info

Definition at line 30 of file color_xform.c.

◆ Rast_histogram_eq_fp_colors()

void Rast_histogram_eq_fp_colors ( struct Colors dst,
struct Colors src,
struct FP_stats statf 
)

Make histogram-stretched version of existing color table (FP version)

Generates a histogram contrast-stretched color table that goes from the histogram information in the FP_stats structure statf. (See Raster Histograms).

Parameters
[out]dststruct to hold new colors
srcstruct containing original colors
statfcell stats info

Definition at line 107 of file color_xform.c.

◆ Rast_history_length()

int Rast_history_length ( struct History hist)

Definition at line 334 of file raster/history.c.

References History::nlines.

◆ Rast_history_line()

const char* Rast_history_line ( struct History hist,
int  line 
)

Definition at line 339 of file raster/history.c.

◆ Rast_init()

void Rast_init ( void  )

Initialize GRASS GIS engine.

Initializes GIS engine and ensures a valid mapset is available.

Returns
always returns 0 on success
exit() is called on error

Definition at line 43 of file raster/init.c.

References Rast__init().

Referenced by Rast_read_fp_range(), Rast_read_rstats(), Rast_write_fp_range(), and Rast_write_rstats().

◆ Rast_init_all()

void Rast_init_all ( void  )

Definition at line 143 of file raster/init.c.

References Rast__check_for_auto_masking(), Rast__init(), and Rast_init_gdal().

◆ Rast_init_cats()

void Rast_init_cats ( const char *  title,
struct Categories pcats 
)

Initialize category structure.

To construct a new category file, the structure must first be initialized. This routine initializes the cats structure, and copies the title into the structure. The number of categories is set initially to n.

For example:

struct Categories cats;
Rast_init_cats ("", &cats);
void Rast_init_cats(const char *, struct Categories *)
Initialize category structure.
Definition: raster/cats.c:1145
Todo:
Eliminate pcats->num. Num has no meaning in new Categories structure and only stores (int) largest data value for backwards compatibility.
Parameters
titletitle
pcatspointer to Categories structure

Definition at line 1145 of file raster/cats.c.

References Categories::a1, Categories::a2, Categories::fmt, Categories::labels, Categories::last_marked_rule, Categories::m1, Categories::m2, Categories::nalloc, Categories::ncats, NULL, Categories::num, Categories::q, Rast_quant_init(), and Rast_set_cats_title().

Referenced by Rast_copy_cats().

◆ Rast_init_cell_stats()

void Rast_init_cell_stats ( struct Cell_stats s)

Initialize cell stats.

This routine, which must be called first, initializes the Cell_stats structure.

Set the count for NULL-values to zero.

Parameters
spointer to Cell_stats structure

Definition at line 39 of file cell_stats.c.

◆ Rast_init_colors()

void Rast_init_colors ( struct Colors colors)

Initialize color structure.

The colors structure is initialized for subsequent calls to Rast_add_c_color_rule() and Rast_set_c_color().

Parameters
colorspointer to Colors structure

Definition at line 25 of file color_init.c.

◆ Rast_init_fp_range()

void Rast_init_fp_range ( struct FPRange range)

Initialize fp range.

Must set a flag in the range structure that indicates that no min/max have been defined - probably a "first" boolean flag.

Parameters
rangepointer to FPRange which holds fp range info

Definition at line 746 of file raster/range.c.

References FPRange::max, FPRange::min, and Rast_set_d_null_value().

Referenced by Rast3d_range_init(), Rast3d_read_range(), and Rast_read_fp_range().

◆ Rast_init_gdal()

void Rast_init_gdal ( void  )

Initialization.

Register all GDAL drivers.

Definition at line 39 of file gdal.c.

Referenced by Rast_create_gdal_link(), and Rast_init_all().

◆ Rast_init_histogram()

void Rast_init_histogram ( struct Histogram histogram)

initializes the histogram structure

initializes the histogram structure for calls to Rast_set_histogram() and Rast_add_histogram()

Parameters
histogram
Returns

Definition at line 22 of file histogram.c.

References Histogram::list, NULL, and Histogram::num.

Referenced by Rast_make_histogram_cs(), and Rast_read_histogram().

◆ Rast_init_range()

void Rast_init_range ( struct Range range)

Initialize range structure.

Initializes the range structure for updates by Rast_update_range() and Rast_row_update_range().

Must set a flag in the range structure that indicates that no min/max have been defined - probably a "first" boolean flag.

Parameters
rangepointer to Range structure which holds range info

Definition at line 694 of file raster/range.c.

References Range::max, Range::min, and Rast_set_c_null_value().

Referenced by Rast_read_range().

◆ Rast_input_window_cols()

int Rast_input_window_cols ( void  )

Number of columns in active input window.

This routine returns the number of columns in the active input window.

Returns
number of columns

Definition at line 158 of file raster/window.c.

References Cell_head::cols, Rast__init_window(), and R__::rd_window.

Referenced by Rast_allocate_c_input_buf(), Rast_allocate_d_input_buf(), Rast_allocate_f_input_buf(), Rast_allocate_input_buf(), Rast_allocate_null_input_buf(), and Rast_zero_input_buf().

◆ Rast_input_window_rows()

int Rast_input_window_rows ( void  )

Number of rows in active input window.

This routine returns the number of rows in the active input window.

Returns
number of rows

Definition at line 144 of file raster/window.c.

References Rast__init_window(), R__::rd_window, and Cell_head::rows.

◆ Rast_insert_c_null_values()

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 292 of file null_val.c.

◆ Rast_insert_d_null_values()

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 319 of file null_val.c.

◆ Rast_insert_f_null_values()

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 304 of file null_val.c.

◆ Rast_insert_null_values()

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

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

Returns 1 if cell is NULL, 0 otherwise. This will test if the value cell is the largest int.

Parameters
cellValCELL raster value to check
Returns
TRUE if CELL raster value is NULL
FALSE otherwise

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

To check if a DCELL raster value is set to NULL

Returns 1 if dcell is NULL, 0 otherwise. This will test if the value dcell is a NaN. Same test as in Rast_is_f_null_value().

Parameters
dcellValDCELL raster value to check
Returns
TRUE if DCELL raster value is NULL
FALSE otherwise

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 276 of file null_val.c.

◆ Rast_interp_bicubic()

DCELL Rast_interp_bicubic ( double  u,
double  v,
DCELL  c00,
DCELL  c01,
DCELL  c02,
DCELL  c03,
DCELL  c10,
DCELL  c11,
DCELL  c12,
DCELL  c13,
DCELL  c20,
DCELL  c21,
DCELL  c22,
DCELL  c23,
DCELL  c30,
DCELL  c31,
DCELL  c32,
DCELL  c33 
)

Definition at line 44 of file interp.c.

◆ Rast_interp_bicubic_bspline()

DCELL Rast_interp_bicubic_bspline ( double  u,
double  v,
DCELL  c00,
DCELL  c01,
DCELL  c02,
DCELL  c03,
DCELL  c10,
DCELL  c11,
DCELL  c12,
DCELL  c13,
DCELL  c20,
DCELL  c21,
DCELL  c22,
DCELL  c23,
DCELL  c30,
DCELL  c31,
DCELL  c32,
DCELL  c33 
)

Definition at line 156 of file interp.c.

◆ Rast_interp_bilinear()

DCELL Rast_interp_bilinear ( double  u,
double  v,
DCELL  c00,
DCELL  c01,
DCELL  c10,
DCELL  c11 
)

Definition at line 26 of file interp.c.

◆ Rast_interp_cubic()

DCELL Rast_interp_cubic ( double  u,
DCELL  c0,
DCELL  c1,
DCELL  c2,
DCELL  c3 
)

Definition at line 35 of file interp.c.

◆ Rast_interp_cubic_bspline()

DCELL Rast_interp_cubic_bspline ( double  u,
DCELL  c0,
DCELL  c1,
DCELL  c2,
DCELL  c3 
)

Definition at line 146 of file interp.c.

◆ Rast_interp_lanczos()

DCELL Rast_interp_lanczos ( double  u,
double  v,
DCELL c 
)

Definition at line 57 of file interp.c.

◆ Rast_interp_linear()

DCELL Rast_interp_linear ( double  u,
DCELL  c0,
DCELL  c1 
)

Definition at line 21 of file interp.c.

◆ Rast_invert_colors()

void Rast_invert_colors ( struct Colors colors)

Definition at line 17 of file color_invrt.c.

◆ Rast_is_null_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 176 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 Rast_get_f_value(), Rast_get_vrt_row(), Rast_raster_cmp(), and Rast_row_update_fp_range().

◆ Rast_is_reclass()

int Rast_is_reclass ( const char *  name,
const char *  mapset,
char *  rname,
char *  rmapset 
)

Check if raster map is reclassified.

This function determines if the raster map name in mapset is a reclass file. If it is, then the name and mapset of the referenced raster map are copied into the rname and rmapset buffers.

Parameters
namemap name
mapsetmapset name
[out]rnamename of reference map
[out]rmapsetmapset where reference map lives
Returns
1 if it is a reclass file
0 if it is not
-1 if there was a problem reading the raster header

Definition at line 43 of file reclass.c.

Referenced by Rast__mask_info(), and Rast_get_cellhd().

◆ Rast_is_reclassed_to()

int Rast_is_reclassed_to ( const char *  name,
const char *  mapset,
int *  nrmaps,
char ***  rmaps 
)

Get child reclass maps list.

This function generates a child reclass maps list from the cell_misc/reclassed_to file which stores this list. The cell_misc/reclassed_to file is written by Rast_put_reclass(). Rast_is_reclassed_to() is used by g.rename, g.remove and r.reclass to prevent accidentally deleting the parent map of a reclassed raster map.

Parameters
namemap name
mapsetmapset name
[out]nrmapsnumber of reference maps
[out]rmapsarray of names of reference maps
Returns
number of reference maps
-1 on error

Definition at line 79 of file reclass.c.

References G_fopen_old_misc(), G_malloc, G_realloc, l, name, and NULL.

◆ Rast_legal_semantic_label()

bool Rast_legal_semantic_label ( const char *  semantic_label)

Check for legal semantic label.

Legal semantic label must be a legal GRASS file name. Semantic labels are capped in length to GNAME_MAX.

This function will return false if provided semantic label is not considered to be valid. This function does not check if semantic label maps to any entry in metadata files of semantic labels as not all semantic labels have files with extra metadata.

The function prints a warning on error.

Parameters
semanticlabel reference to check
Returns
true success
false failure

Definition at line 153 of file raster_metadata.c.

◆ Rast_load_colors()

int Rast_load_colors ( struct Colors colors,
const char *  path,
CELL  min,
CELL  max 
)

Load color rules from file.

Parameters
[out]colorspointer to Colors structure
pathpath to the color rules file
min,maxmin & max values (used only when color rules are in percentage)
Returns
0 on failure
1 on success

Definition at line 293 of file raster/color_rules.c.

◆ Rast_load_fp_colors()

int Rast_load_fp_colors ( struct Colors colors,
const char *  path,
DCELL  min,
DCELL  max 
)

Load color floating-point rules from file.

Parameters
[out]colorspointer to Colors structure
pathpath to the color rules file
min,maxmin & max values (used only when color rules are in percentage)
Returns
0 on failure
1 on success

Definition at line 310 of file raster/color_rules.c.

◆ Rast_log_colors()

void Rast_log_colors ( struct Colors dst,
struct Colors src,
int  samples 
)

Make logarithmically-scaled version of an existing color table.

Parameters
[out]dststruct to hold new colors
srcstruct containing original colors
samplesnumber of samples

Definition at line 181 of file color_xform.c.

◆ Rast_lookup_c_colors()

void Rast_lookup_c_colors ( const CELL cell,
unsigned char *  red,
unsigned char *  grn,
unsigned char *  blu,
unsigned char *  set,
int  n,
struct Colors colors 
)

Lookup an array of colors.

Extracts colors for an array of cell values. The colors for the n values in the cell array are stored in the red, green, and blue arrays. The values in the set array will indicate if the corresponding cell value has a color or not (1 means it does, 0 means it does not).

The programmer must allocate the red, green, blue, and set arrays to be at least dimension n.

Note: The red, green, and blue intensities will be in the range 0 - 255.

Modified to return a color for NULL-values.

Parameters
cellraster cell value
[out]redred value
[out]grngreen value
[out]blublue value
setarray which indicates if color is set or not
nnumber of values
colorspointer to Colors structure which holds color info

Definition at line 45 of file color_look.c.

◆ Rast_lookup_colors()

void Rast_lookup_colors ( const void *  raster,
unsigned char *  red,
unsigned char *  grn,
unsigned char *  blu,
unsigned char *  set,
int  n,
struct Colors colors,
RASTER_MAP_TYPE  map_type 
)

Lookup an array of colors.

Parameters
rasterraster cell value
[out]redred value
[out]grngreen value
[out]blublue value
setarray which indicates if color is set or not
nnumber of values
colorspointer to Colors structure which holds color info
map_typeraster type (CELL, FCELL, DCELL)

Definition at line 79 of file color_look.c.

◆ Rast_lookup_d_colors()

void Rast_lookup_d_colors ( const DCELL dcell,
unsigned char *  red,
unsigned char *  grn,
unsigned char *  blu,
unsigned char *  set,
int  n,
struct Colors colors 
)

Lookup an array of colors (DCELL)

Converts the n double-precision values in the dcell array to their r,g,b color components. Embedded NULL-values are handled properly as well.

Parameters
dcellraster cell value
[out]redred value
[out]grngreen value
[out]blublue value
setarray which indicates if color is set or not
nnumber of values
colorspointer to Colors structure which holds color info

Definition at line 146 of file color_look.c.

◆ Rast_lookup_f_colors()

void Rast_lookup_f_colors ( const FCELL fcell,
unsigned char *  red,
unsigned char *  grn,
unsigned char *  blu,
unsigned char *  set,
int  n,
struct Colors colors 
)

Lookup an array of colors (FCELL)

Converts the n floating-point values in the fcell array to their r,g,b color components. Embedded NULL-values are handled properly as well.

Parameters
fcellraster cell value
[out]redred value
[out]grngreen value
[out]blublue value
setarray which indicates if color is set or not
nnumber of values
colorspointer to Colors structure which holds color info

Definition at line 112 of file color_look.c.

◆ Rast_make_aspect_colors()

void Rast_make_aspect_colors ( struct Colors colors,
CELL  min,
CELL  max 
)

Make aspect colors (integer)

Generates a color table for aspect data.

Parameters
colorspointer to Colors structure which holds color info
minminimum value
maxmaximum value

Definition at line 298 of file color_compat.c.

◆ Rast_make_aspect_fp_colors()

void Rast_make_aspect_fp_colors ( struct Colors colors,
DCELL  min,
DCELL  max 
)

Make aspect colors (floating-point)

Generates a color table for aspect data.

Parameters
colorspointer to Colors structure which holds color info
minminimum value
maxmaximum value

Definition at line 312 of file color_compat.c.

◆ Rast_make_bgyr_colors()

void Rast_make_bgyr_colors ( struct Colors colors,
CELL  min,
CELL  max 
)

Create BGYR color table (integer)

Generates a color table blue-green-yellow-red.

Parameters
colorspointer to Colors structure which holds color info
minminimum value
maxmaximum value

Definition at line 242 of file color_compat.c.

◆ Rast_make_bgyr_fp_colors()

void Rast_make_bgyr_fp_colors ( struct Colors colors,
DCELL  min,
DCELL  max 
)

Create BGYR color table (floating-point)

Generates a color table blue-green-yellow-red.

Parameters
colorspointer to Colors structure which holds color info
minminimum value
maxmaximum value

Definition at line 256 of file color_compat.c.

◆ Rast_make_byg_colors()

void Rast_make_byg_colors ( struct Colors colors,
CELL  min,
CELL  max 
)

Create BYG color table (integer)

Generates a color table blue-yellow-green.

Parameters
colorspointer to Colors structure which holds color info
minminimum value
maxmaximum value

Definition at line 270 of file color_compat.c.

◆ Rast_make_byg_fp_colors()

void Rast_make_byg_fp_colors ( struct Colors colors,
DCELL  min,
DCELL  max 
)

Create BYG color table (floating-point)

Generates a color table blue-yellow-green.

Parameters
colorspointer to Colors structure which holds color info
minminimum value
maxmaximum value

Definition at line 284 of file color_compat.c.

◆ Rast_make_byr_colors()

void Rast_make_byr_colors ( struct Colors colors,
CELL  min,
CELL  max 
)

Create BYR color table (integer)

Generates a color table blue-yellow-red.

Parameters
colorspointer to Colors structure which holds color info
minminimum value
maxmaximum value

Definition at line 214 of file color_compat.c.

◆ Rast_make_byr_fp_colors()

void Rast_make_byr_fp_colors ( struct Colors colors,
DCELL  min,
DCELL  max 
)

Create BYR color table (floating-point)

Generates a color table blue-yellow-red.

Parameters
colorspointer to Colors structure which holds color info
minminimum value
maxmaximum value

Definition at line 228 of file color_compat.c.

◆ Rast_make_colors()

void Rast_make_colors ( struct Colors colors,
const char *  name,
CELL  min,
CELL  max 
)

Load color rules from predefined color table.

Parameters
[out]colorspointer to Colors structure
namename of color table to load
min,maxmin & max values (used only when color rules are in percentage)

Definition at line 335 of file raster/color_rules.c.

◆ Rast_make_fp_colors()

void Rast_make_fp_colors ( struct Colors colors,
const char *  name,
DCELL  min,
DCELL  max 
)

Load color rules from predefined floating-point color table.

Parameters
[out]colorspointer to Colors structure
namename of color table to load
min,maxmin & max values (used only when color rules are in percentage)

Definition at line 349 of file raster/color_rules.c.

◆ Rast_make_grey_scale_colors()

void Rast_make_grey_scale_colors ( struct Colors colors,
CELL  min,
CELL  max 
)

Make linear grey scale (integer)

Generates a grey scale color table. Each color is a level of grey, increasing from black to white.

Parameters
colorspointer to Colors structure which holds color info
minminimum value
maxmaximum value

Definition at line 185 of file color_compat.c.

◆ Rast_make_grey_scale_fp_colors()

void Rast_make_grey_scale_fp_colors ( struct Colors colors,
DCELL  min,
DCELL  max 
)

Make linear grey scale (floating-point)

Generates a grey scale color table. Each color is a level of grey, increasing from black to white.

Parameters
colorspointer to Colors structure which holds color info
minminimum value
maxmaximum value

Definition at line 200 of file color_compat.c.

◆ Rast_make_gyr_colors()

void Rast_make_gyr_colors ( struct Colors colors,
CELL  min,
CELL  max 
)

Create GYR color table (integer)

Generates a color table green-yellow-red.

Parameters
colorspointer to Colors structure which holds color info
minminimum value
maxmaximum value

Definition at line 156 of file color_compat.c.

◆ Rast_make_gyr_fp_colors()

void Rast_make_gyr_fp_colors ( struct Colors colors,
DCELL  min,
DCELL  max 
)

Create GYR color table (floating-point)

Generates a color table green-yellow-red.

Parameters
colorspointer to Colors structure which holds color info
minminimum value
maxmaximum value

Definition at line 170 of file color_compat.c.

◆ Rast_make_histogram_cs()

void Rast_make_histogram_cs ( struct Cell_stats statf,
struct Histogram histogram 
)

Creates histogram based on cell statistics.

Parameters
statfcell statistics
histogramraster histogram
Returns

Definition at line 136 of file histogram.c.

References count, Rast_add_histogram(), Rast_init_histogram(), Rast_next_cell_stat(), Rast_rewind_cell_stats(), and Rast_sort_histogram().

◆ Rast_make_histogram_eq_colors()

void Rast_make_histogram_eq_colors ( struct Colors colors,
struct Cell_stats statf 
)

Make histogram-stretched grey colors.

Generates a histogram contrast-stretched grey scale color table that goes from the, histogram information in the Cell_stats structure (see Raster Histograms).

Color range is 0-255.

Parameters
colorspointer to Colors structure which holds color info
statfpointer to Cell_stats structure which holds cell stats info

Definition at line 32 of file color_hist.c.

◆ Rast_make_histogram_log_colors()

void Rast_make_histogram_log_colors ( struct Colors colors,
struct Cell_stats statf,
int  min,
int  max 
)

Generates histogram with normalized log transformed grey scale.

Generates histogram with normalized log transformed grey scale from cell stats structure info. Color range is 0-255.

Parameters
colorspointer to Colors structure which holds color info
statfpointer to Cell_stats structure which holds cell stats info
minminimum value
maxmaximum value

Definition at line 101 of file color_hist.c.

◆ Rast_make_rainbow_colors()

void Rast_make_rainbow_colors ( struct Colors colors,
CELL  min,
CELL  max 
)

Make rainbow colors (integer)

Generates a "shifted" rainbow color table - yellow to green to cyan to blue to magenta to red. The color table is based on rainbow colors. (Normal rainbow colors are red, orange, yellow, green, blue, indigo, and violet.) This table is good for continuous data, such as elevation.

Parameters
colorspointer to Colors structure which holds color info
minminimum value
maxmaximum value

Definition at line 124 of file color_compat.c.

◆ Rast_make_rainbow_fp_colors()

void Rast_make_rainbow_fp_colors ( struct Colors colors,
DCELL  min,
DCELL  max 
)

Make rainbow colors (floating-point)

Generates a "shifted" rainbow color table - yellow to green to cyan to blue to magenta to red. The color table is based on rainbow colors. (Normal rainbow colors are red, orange, yellow, green, blue, indigo, and violet.) This table is good for continuous data, such as elevation.

Parameters
colorspointer to Colors structure which holds color info
minminimum value
maxmaximum value

Definition at line 142 of file color_compat.c.

◆ Rast_make_ramp_colors()

void Rast_make_ramp_colors ( struct Colors colors,
CELL  min,
CELL  max 
)

Make color ramp (integer)

Generates a color table with 3 sections: red only, green only, and blue only, each increasing from none to full intensity. This table is good for continuous data, such as elevation.

Parameters
colorspointer to Colors structure which holds color info
minminimum value
maxmaximum value

Definition at line 90 of file color_compat.c.

◆ Rast_make_ramp_fp_colors()

void Rast_make_ramp_fp_colors ( struct Colors colors,
DCELL  min,
DCELL  max 
)

Make color ramp (floating-point)

Generates a color table with 3 sections: red only, green only, and blue only, each increasing from none to full intensity. This table is good for continuous data, such as elevation.

Parameters
colorspointer to Colors structure which holds color info
minminimum value
maxmaximum value

Definition at line 106 of file color_compat.c.

◆ Rast_make_random_colors()

void Rast_make_random_colors ( struct Colors colors,
CELL  min,
CELL  max 
)

make random colors

Generates random colors. Good as a first pass at a color table for nominal data.

Parameters
colors
min
max
Returns

Definition at line 24 of file color_rand.c.

◆ Rast_make_ryg_colors()

void Rast_make_ryg_colors ( struct Colors colors,
CELL  min,
CELL  max 
)

Create RYG color table (integer)

Generates a color table red-yellow-green.

Parameters
colorspointer to Colors structure which holds color info
minminimum value
maxmaximum value

Definition at line 60 of file color_compat.c.

◆ Rast_make_ryg_fp_colors()

void Rast_make_ryg_fp_colors ( struct Colors colors,
DCELL  min,
DCELL  max 
)

Create RYG color table (floating-point)

Generates a color table red-yellow-green.

Parameters
colorspointer to Colors structure which holds color info
minminimum value
maxmaximum value

Definition at line 74 of file color_compat.c.

◆ Rast_make_wave_colors()

void Rast_make_wave_colors ( struct Colors colors,
CELL  min,
CELL  max 
)

Make color wave (integer)

Generates a color table with 3 sections: red only, green only, and blue only, each increasing from none to full intensity and back down to none. This table is good for continuous data like elevation.

Parameters
colorspointer to Colors structure which holds color info
minminimum value
maxmaximum value

Definition at line 29 of file color_compat.c.

◆ Rast_make_wave_fp_colors()

void Rast_make_wave_fp_colors ( struct Colors colors,
DCELL  min,
DCELL  max 
)

Make color wave (floating-point)

Generates a color table with 3 sections: red only, green only, and blue only, each increasing from none to full intensity and back down to none. This table is good for continuous data like elevation.

Parameters
colorspointer to Colors structure which holds color info
minminimum value
maxmaximum value

Definition at line 46 of file color_compat.c.

◆ Rast_map_is_fp()

int Rast_map_is_fp ( const char *  name,
const char *  mapset 
)

Check if raster map is floating-point.

Returns true (1) if raster map name in mapset is a floating-point dataset; false(0) otherwise.

Parameters
namemap name
mapsetmapset name
Returns
1 floating-point
0 int

Definition at line 861 of file raster/open.c.

References _, G_fatal_error(), G_file_name(), G_find_raster2(), G_fully_qualified_name(), GPATH_MAX, fileinfo::mapset, and name.

◆ Rast_map_to_img_str()

int Rast_map_to_img_str ( char *  name,
int  color_mode,
unsigned char *  result 
)

Definition at line 58 of file rast_to_img_string.c.

References NULL.

◆ Rast_map_type()

RASTER_MAP_TYPE Rast_map_type ( const char *  name,
const char *  mapset 
)

Determine raster data type.

Determines if the raster map is floating point or integer. Returns DCELL_TYPE for double maps, FCELL_TYPE for float maps, CELL_TYPE for integer maps, -1 if error has occurred

Parameters
namemap name
mapsetmapset where map name lives
Returns
raster data type

Definition at line 894 of file raster/open.c.

References _, CELL_TYPE, DCELL_TYPE, G_fatal_error(), G_file_name(), G_find_raster2(), GPATH_MAX, fileinfo::mapset, name, and Rast__check_fp_type().

Referenced by Rast__open_old(), Rast__quant_import(), Rast_read_fp_range(), Rast_read_range(), Rast_write_quant(), and Rast_write_range().

◆ Rast_mark_c_cats()

void Rast_mark_c_cats ( const CELL rast_row,
int  ncols,
struct Categories pcats 
)

Looks up the category label for each raster value (CELL).

Looks up the category label for each raster value in the rast_row and updates the marks for labels found.

Note: Non-zero mark for i-th label stores the number of of raster cells read so far which are labeled with i-th label and fall into i-th data range.

Parameters
rast_rowraster row to update stats
ncolsnumber of columns
pcatspointer to Categories structure

Definition at line 492 of file raster/cats.c.

◆ Rast_mark_cats()

int Rast_mark_cats ( const void *  rast_row,
int  ncols,
struct Categories pcats,
RASTER_MAP_TYPE  data_type 
)

Looks up the category label for each raster value (DCELL).

Looks up the category label for each raster value in the rast_row and updates the marks for labels found.

Note: Non-zero mark for i-th label stores the number of of raster cells read so far which are labeled with i-th label and fall into i-th data range.

Parameters
rast_rowraster row to update stats
ncolsnumber of columns
pcatspointer to Categories structure
data_typemap type
Returns
-1 on error
1 on success

Definition at line 557 of file raster/cats.c.

◆ Rast_mark_colors_as_fp()

void Rast_mark_colors_as_fp ( struct Colors colors)

Mark colors as floating-point.

Sets a flag in the colors structure that indicates that these colors should only be looked up using floating-point raster data (not integer data). In particular if this flag is set, the routine Rast_get_c_colors_min_max() should return min=-255$^3$ and max=255$^3$.

Parameters
colorspointer to Colors structure

Definition at line 393 of file raster/color_read.c.

◆ Rast_mark_d_cats()

void Rast_mark_d_cats ( const DCELL rast_row,
int  ncols,
struct Categories pcats 
)

Looks up the category label for each raster value (DCELL).

Looks up the category label for each raster value in the rast_row and updates the marks for labels found.

Note: Non-zero mark for i-th label stores the number of of raster cells read so far which are labeled with i-th label and fall into i-th data range.

Parameters
rast_rowraster row to update stats
ncolsnumber of columns
pcatspointer to Categories structure

Definition at line 533 of file raster/cats.c.

◆ Rast_mark_f_cats()

void Rast_mark_f_cats ( const FCELL rast_row,
int  ncols,
struct Categories pcats 
)

Looks up the category label for each raster value (FCELL).

Looks up the category label for each raster value in the rast_row and updates the marks for labels found.

Note: Non-zero mark for i-th label stores the number of of raster cells read so far which are labeled with i-th label and fall into i-th data range.

Parameters
rast_rowraster row to update stats
ncolsnumber of columns
pcatspointer to Categories structure

Definition at line 512 of file raster/cats.c.

◆ Rast_mask_info()

char* Rast_mask_info ( void  )

Definition at line 35 of file mask_info.c.

References _, G_store(), GMAPSET_MAX, GNAME_MAX, name, Rast__mask_info(), and strcpy.

◆ Rast_maskfd()

int Rast_maskfd ( void  )

Test for MASK.

Returns
-1 if no MASK
file descriptor if MASK

Definition at line 26 of file maskfd.c.

References R__::auto_mask, R__::mask_fd, and Rast__check_for_auto_masking().

Referenced by IL_create_bitmask().

◆ Rast_next_cell_stat()

int Rast_next_cell_stat ( CELL cat,
long *  count,
struct Cell_stats s 
)

Retrieve sorted cell stats.

Retrieves the next cat, count combination from the structure. Returns 0 if there are no more items, non-zero if there are more. For example:

struct Cell_stats s;
CELL cat;
long count;
// updating <b>s</b> occurs here
while (Rast_next_cell_stat(&cat,&count,&s)
fprintf(stdout, "%ld %ld\n", (long) cat, count);
int Rast_rewind_cell_stats(struct Cell_stats *)
Reset/rewind cell stats.
Definition: cell_stats.c:248
int Rast_next_cell_stat(CELL *, long *, struct Cell_stats *)
Retrieve sorted cell stats.
Definition: cell_stats.c:312
int count

Do not return a record for the NULL-value

Parameters
catraster value
[out]count
spointer to Cell_stats structure which holds cell stats info
Returns
0 if there are no more items
non-zero if there are more

Definition at line 312 of file cell_stats.c.

Referenced by Rast_make_histogram_cs().

◆ Rast_northing_to_row()

double Rast_northing_to_row ( double  north,
const struct Cell_head window 
)

Northing to row.

Converts a northing relative to a window to a row.

Note: The result is a double. Casting it to an integer will give the row number.

Parameters
northnorthing value
windowpointer to Cell_head
Returns
row number

Definition at line 207 of file raster/window.c.

◆ Rast_number_of_cats()

int Rast_number_of_cats ( struct Categories pcats)

Get number of raster categories.

Parameters
pcatspointer to Categories structure
Returns
number of categories

Definition at line 1269 of file raster/cats.c.

References Categories::ncats.

◆ Rast_open_c_new()

int Rast_open_c_new ( const char *  name)

Opens a new cell file in a database (compressed)

Opens a new cell file name in the current mapset for writing by Rast_put_row().

The file is created and filled with no data it is assumed that the new cell file is to conform to the current window.

The file must be written sequentially. Use Rast_open_new_random() for non sequential writes.

Note: the open actually creates a temporary file Rast_close() will move the temporary file to the cell file and write out the necessary support files (cellhd, cats, hist, etc.).

Diagnostics: warning message printed if open fails

Warning: calls to Rast_set_window() made after opening a new cell file may create confusion and should be avoided the new cell file will be created to conform to the window at the time of the open.

Parameters
namemap name
Returns
open file descriptor ( >= 0) if successful
negative integer if error

Definition at line 418 of file raster/open.c.

◆ Rast_open_c_new_uncompressed()

int Rast_open_c_new_uncompressed ( const char *  name)

Opens a new cell file in a database (uncompressed)

See also Rast_open_new().

Parameters
namemap name
Returns
open file descriptor ( >= 0) if successful
negative integer if error

Definition at line 433 of file raster/open.c.

◆ Rast_open_fp_new()

int Rast_open_fp_new ( const char *  name)

Opens new fcell file in a database.

Opens a new floating-point map name in the current mapset for writing. The type of the file (i.e. either double or float) is determined and fixed at this point. The default is FCELL_TYPE. In order to change this default

Use Rast_set_fp_type() where type is one of DCELL_TYPE or FCELL_TYPE.

See warnings and notes for Rast_open_new().

Parameters
namemap name
Returns
nonnegative file descriptor (int)

Definition at line 507 of file raster/open.c.

◆ Rast_open_fp_new_uncompressed()

int Rast_open_fp_new_uncompressed ( const char *  name)

Opens new fcell file in a database (uncompressed)

See Rast_open_fp_new() for details.

Parameters
namemap name
Returns
nonnegative file descriptor (int)

Definition at line 521 of file raster/open.c.

◆ Rast_open_new()

int Rast_open_new ( const char *  name,
RASTER_MAP_TYPE  wr_type 
)

Opens a new raster map.

Opens a new raster map of type wr_type

See warnings and notes for Rast_open_new().

Supported data types:

  • CELL_TYPE
  • FCELL_TYPE
  • DCELL_TYPE

On CELL_TYPE calls Rast_open_new() otherwise Rast_open_fp_new().

Parameters
namemap name
wr_typeraster data type
Returns
nonnegative file descriptor (int)

Definition at line 1013 of file raster/open.c.

◆ Rast_open_new_uncompressed()

int Rast_open_new_uncompressed ( const char *  name,
RASTER_MAP_TYPE  wr_type 
)

Opens a new raster map (uncompressed)

See Rast_open_new().

Parameters
namemap name
wr_typeraster data type
Returns
nonnegative file descriptor (int)

Definition at line 1028 of file raster/open.c.

◆ Rast_open_old()

int Rast_open_old ( const char *  name,
const char *  mapset 
)

Open an existing integer raster map (cell)

Opens the existing cell file name in the mapset for reading by Rast_get_row() with mapping into the current window.

This routine opens the raster map name in mapset for reading. A nonnegative file descriptor is returned if the open is successful. Otherwise a diagnostic message is printed and a negative value is returned. This routine does quite a bit of work. Since GRASS users expect that all raster maps will be resampled into the current region, the resampling index for the raster map is prepared by this routine after the file is opened. The resampling is based on the active module region (see also The_Region}. Preparation required for reading the various raster file formats (see Raster_File_Format for an explanation of the various raster file formats) is also done.

Diagnostics: warning message printed if open fails.

Parameters
namemap name
mapsetmapset name where raster map name lives
Returns
nonnegative file descriptor (int)

Definition at line 112 of file raster/open.c.

References name, Rast__check_for_auto_masking(), and Rast__open_old().

Referenced by IL_create_bitmask(), and open_band_files().

◆ Rast_option_to_interp_type()

int Rast_option_to_interp_type ( const struct Option option)

Get interpolation method from the option.

Calls G_fatal_error() on unknown interpolation method.

Supported methods:

  • NEAREST
  • BILINEAR
  • CUBIC
int interp_method
struct Option *opt_method;
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
interp_method = G_option_to_interp_type(opt_method);
int G_parser(int, char **)
Parse command line.
Definition: parser.c:321
struct Option * G_define_standard_option(int)
Create standardised Option structure.
@ G_OPT_R_INTERP_TYPE
Definition: gis.h:284
Structure that stores option information.
Definition: gis.h:554
Parameters
optionpointer to interpolation option
Returns
interpolation method code

Definition at line 196 of file interp.c.

References _, Option::answer, G_fatal_error(), INTERP_BICUBIC, INTERP_BILINEAR, INTERP_NEAREST, and INTERP_UNKNOWN.

◆ Rast_output_window_cols()

int Rast_output_window_cols ( void  )

Number of columns in active output window.

This routine returns the number of columns in the active output window.

Returns
number of columns

Definition at line 186 of file raster/window.c.

References Cell_head::cols, Rast__init_window(), and R__::wr_window.

Referenced by Rast_allocate_c_output_buf(), Rast_allocate_d_output_buf(), Rast_allocate_f_output_buf(), Rast_allocate_null_output_buf(), Rast_allocate_output_buf(), and Rast_zero_output_buf().

◆ Rast_output_window_rows()

int Rast_output_window_rows ( void  )

Number of rows in active output window.

This routine returns the number of rows in the active output window.

Returns
number of rows

Definition at line 172 of file raster/window.c.

References Rast__init_window(), Cell_head::rows, and R__::wr_window.

◆ Rast_parse_color_rule()

int Rast_parse_color_rule ( DCELL  min,
DCELL  max,
const char *  buf,
DCELL val,
int *  r,
int *  g,
int *  b,
int *  norm,
int *  nval,
int *  dflt 
)

Read color rule.

The val output parameter is always an absolute value and is derived from the rule and the min and max values in case the rule is in percents.

Always only one of the norm, nval, and dflt output parameters is set to non-zero value, the others are set to zero.

The return code can be translated to an error message using the Rast_parse_color_rule_error() function.

Parameters
min,maxmin & max values (used only when color rules are in percentage)
bufstring with the color rule
[out]valvalue which the color is assigned to
[out]r,g,bcolor values
[out]normset to non-zero value if the value and color are set
[out]nvalset to non-zero value if rule is for null value
[out]dfltset to non-zero value if rule specifies the default color
Returns
enum rule_error values (non-zero on failure)

Definition at line 57 of file raster/color_rules.c.

◆ Rast_parse_color_rule_error()

const char* Rast_parse_color_rule_error ( int  code)

Parse color rule.

Parameters
code
Returns
pointer to buffer with error message

Definition at line 111 of file raster/color_rules.c.

References _, CR_ERROR_COLOR_SYNTAX, CR_ERROR_PERCENT, CR_ERROR_RULE_SYNTAX, CR_ERROR_VALUE, and CR_OK.

◆ Rast_print_colors()

void Rast_print_colors ( struct Colors colors,
DCELL  min,
DCELL  max,
FILE *  fp,
int  perc 
)

Print color table.

Parameters
colorspointer to Colors structure
min,maxminimum and maximum value for percentage output (used only when perc is non-zero)
fpfile where to print color table rules
percTRUE for percentage output

Definition at line 42 of file color_out.c.

◆ Rast_put_c_row()

void Rast_put_c_row ( int  fd,
const CELL buf 
)

Writes the next row for cell file (CELL version)

See Rast_put_row() for details.

Parameters
fdfile descriptor where data is to be written
bufbuffer holding data
Returns
void

Definition at line 80 of file raster/put_row.c.

References CELL_TYPE, and Rast_put_row().

◆ Rast_put_cell_title()

int Rast_put_cell_title ( const char *  name,
const char *  title 
)

Definition at line 15 of file put_title.c.

◆ Rast_put_cellhd()

void Rast_put_cellhd ( const char *  name,
struct Cell_head cellhd 
)

Writes the raster file header.

Writes the cell file header information associated with map layer "map" into current mapset from the structure "cellhd".

Parameters
namename of map
cellhdstructure holding cell header info
Returns
void

Definition at line 28 of file put_cellhd.c.

References _, G__write_Cell_head(), G_fatal_error(), G_fopen_new(), and name.

◆ Rast_put_d_row()

void Rast_put_d_row ( int  fd,
const DCELL buf 
)

Writes the next row for dcell file (DCELL version)

See Rast_put_row() for details.

Parameters
fdfile descriptor where data is to be written
bufbuffer holding data
Returns
void

Definition at line 110 of file raster/put_row.c.

References DCELL_TYPE, and Rast_put_row().

◆ Rast_put_f_row()

void Rast_put_f_row ( int  fd,
const FCELL buf 
)

Writes the next row for fcell file (FCELL version)

See Rast_put_row() for details.

Parameters
fdfile descriptor where data is to be written
bufbuffer holding data
Returns
void

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

References FCELL_TYPE, and Rast_put_row().

◆ Rast_put_reclass()

int Rast_put_reclass ( const char *  name,
const struct Reclass reclass 
)

Put reclass.

Parameters
namemap name
reclasspointer to Reclass structure
Returns
-1 on error
1 on success

Definition at line 262 of file reclass.c.

References _, G_fatal_error(), GNAME_MAX, GPATH_MAX, Reclass::max, max, Reclass::min, min, Reclass::num, RECLASS_TABLE, and Reclass::type.

◆ Rast_put_row()

void Rast_put_row ( int  fd,
const void *  buf,
RASTER_MAP_TYPE  data_type 
)

Writes the next row for cell/fcell/dcell file.

Writes the next row for the cell file opened on 'fd' from 'buf' All writes go into NEW files that exactly match the current window. The file must have been opened with Rast_open_new() and be written sequentially, ie no skipping rows.

When the null values are embedded into the data, corresponding cells are changed to 0's and the corresponding null value row is written into null file.

A map cannot be copied using Rast_get_row() and Rast_put_row(). The former resamples the data of the original map into a row buffer that matches the current window. The later writes out rows associated with the window.

Keeps track of the minimum and maximum cell value for use in updating the range file upon close of the cell file. HOWEVER when nulls are not embedded, the cells are considered 0's as far as updating range is concerned, even if the corresponding cell is null in the resulting null file, so programmer should be carefult to set all the null values using Rast_set_null_value() or G_insert_d_null_values() or G_insert_f_null_values().

Parameters
fdfile descriptor where data is to be written
bufbuffer holding data
data_typeraster map type (CELL_TYPE, FCELL_TYPE, DCELL_TYPE)
Returns
void

Definition at line 65 of file raster/put_row.c.

Referenced by Rast_put_c_row(), Rast_put_d_row(), and Rast_put_f_row().

◆ Rast_quant_add_rule()

void Rast_quant_add_rule ( struct Quant q,
DCELL  dLow,
DCELL  dHigh,
CELL  cLow,
CELL  cHigh 
)

Adds a new rule to the set of quantization rules.

If dLow < dHigh the rule will be stored with the low and high values interchanged.

Note: currently no cleanup of rules is performed, i.e. redundant rules are not removed. This can't be changed because Categories structure HEAVILY depends of quant rules stored in exactly the same order they are entered. So if the cleanup or rearrangement is done in the future make a flag for add_rule whether or not to do it, then quant will not set this flag.

Parameters
qpointer to Quant structure which holds quant rules info
dLowminimum fp value
dHighmaximum fp value
cLowminimum value
cHighmaximum value

Definition at line 469 of file quant.c.

Referenced by Rast_quantize_fp_map_range(), Rast_set_d_cat(), and Rast_set_quant_rules().

◆ Rast_quant_clear()

void Rast_quant_clear ( struct Quant q)

Resets the number of defined rules and number of infinite rules to 0.

Parameters
qpointer to Quant structure to be reset

Definition at line 41 of file quant.c.

References Quant::infiniteLeftSet, Quant::infiniteRightSet, and Quant::nofRules.

Referenced by Rast_quant_free(), and Rast_quant_init().

◆ Rast_quant_free()

void Rast_quant_free ( struct Quant q)

Resets and frees allocated memory.

Resets the number of defined rules to 0 and free's space allocated for rules. Calls Rast_quant_clear().

Parameters
qpointer to Quant structure to be reset

Definition at line 55 of file quant.c.

References Quant::active, Quant::fp_lookup, G_free(), Quant::maxNofRules, Quant::nalloc, Rast_quant_clear(), Quant::rules, Quant::table, and Quant::vals.

Referenced by Rast__quant_import(), and Rast_free_cats().

◆ Rast_quant_get_cell_value()

CELL Rast_quant_get_cell_value ( struct Quant q,
DCELL  dcellVal 
)

Returns a CELL category for the floating-point value based on the quantization rules in q. The first rule found that applies is used. The rules are searched in the reverse order they are added to q. If no rule is found, the value is first tested against the negative infinite rule, and finally against the positive infinite rule. If none of these rules apply, the NULL-value is returned.

Note: See G_quant_organize_fp_lookup() for details on how the values are looked up from fp_lookup table when it is active. Right now fp_lookup is automatically organized during the first call to Rast_quant_get_cell_value().

Parameters
qpointer to Quant structure which holds quant rules info
dcellValuefp cell value
Returns
cell value (integer)

Definition at line 592 of file quant.c.

Referenced by Rast_quant_perform_d(), and Rast_quant_perform_f().

◆ Rast_quant_get_ith_rule()

void Rast_quant_get_ith_rule ( const struct Quant q,
int  i,
DCELL dLow,
DCELL dHigh,
CELL cLow,
CELL cHigh 
)

Returns the i'th quantization rule.

For 0 <= i < Rast_quant_nof_rules(). A larger value for i means that the rule has been added later.

Parameters
qpointer to Quant structure which holds quant rules info
iindex
[out]dLowminimum fp value
[out]dHighmaximum fp value
[out]cLowminimum value
[out]cHighmaximum value

Definition at line 327 of file quant.c.

References Quant_table::cHigh, Quant_table::cLow, Quant_table::dHigh, Quant_table::dLow, and Quant::table.

Referenced by Rast_get_ith_d_cat().

◆ Rast_quant_get_limits()

int Rast_quant_get_limits ( const struct Quant q,
DCELL dMin,
DCELL dMax,
CELL cMin,
CELL cMax 
)

Returns the minimum and maximum cell and dcell values of all the ranges defined.

Extracts the minimum and maximum floating-point and integer values from all the rules (except the "infinite" rules) in q into dmin, dmax, cmin, and cmax.

Parameters
quantpointer to Quant structure which holds quant rules info
[out]dminminimum fp value
[out]dmaxmaximum fp value
[out]cminminimum value
[out]cmaxmaximum value
Returns
-1 if q->truncate or q->round are true or after Rast_quant_init (), or any call to Rast_quant_clear () or Rast_quant_free() no explicit rules have been added. In this case the returned minimum and maximum CELL and DCELL values are null.
1 if there are any explicit rules
0 if there are no explicit rules (this includes cases when q is set to truncate or round map), and sets dmin, dmax, cmin, and cmax to NULL.

Definition at line 281 of file quant.c.

References Quant::cMax, Quant::cMin, Quant::dMax, Quant::dMin, NO_EXPLICIT_RULE, Rast_set_c_null_value(), and Rast_set_d_null_value().

Referenced by Rast_read_range(), and Rast_write_quant().

◆ Rast_quant_get_neg_infinite_rule()

int Rast_quant_get_neg_infinite_rule ( const struct Quant q,
DCELL dLeft,
CELL c 
)

Returns in "dLeft" and "c" the rule values.

For the negative infinite interval (see Rast_quant_set_neg_infinite_rule()).

Parameters
qpointer to Quant structure which holds quant rules info
[out]dLeftfp value
[out]cvalue
Returns
0 if this rule is not defined
1 otherwise

Definition at line 390 of file quant.c.

Referenced by Rast_set_quant_rules().

◆ Rast_quant_get_pos_infinite_rule()

int Rast_quant_get_pos_infinite_rule ( const struct Quant q,
DCELL dRight,
CELL c 
)

Returns in "dRight" and "c" the rule values.

For the positive infinite interval (see Rast_quant_set_pos_infinite_rule()).

Parameters
qpointer to Quant structure which holds quant rules info
[out]dRightfp value
[out]cvalue
Returns
0 if this rule is not defined
1 otherwise

Definition at line 438 of file quant.c.

Referenced by Rast_set_quant_rules().

◆ Rast_quant_init()

void Rast_quant_init ( struct Quant quant)

Initialize the structure.

Initializes the q struct.

Parameters
quantpointer to Quant structure to be initialized

Definition at line 175 of file quant.c.

References Quant::active, Quant::fp_lookup, Quant::maxNofRules, Rast_quant_clear(), Quant::round_only, and Quant::truncate_only.

Referenced by Rast_init_cats(), Rast_quantize_fp_map_range(), Rast_read_quant(), Rast_round_fp_map(), Rast_set_quant_rules(), and Rast_truncate_fp_map().

◆ Rast_quant_is_round()

int Rast_quant_is_round ( const struct Quant quant)

Returns whether or not quant rules are set to round map.

Parameters
quantpointer to Quant structure which holds quant rules info
Returns
1 is round
0 not round

Definition at line 204 of file quant.c.

References Quant::round_only.

Referenced by Rast_read_range().

◆ Rast_quant_is_truncate()

int Rast_quant_is_truncate ( const struct Quant quant)

Returns whether or not quant rules are set to truncate map.

Parameters
quantpointer to Quant structure which holds quant rules info
Returns
1 if truncate is enable
0 if not truncated

Definition at line 192 of file quant.c.

References Quant::truncate_only.

Referenced by Rast_read_range().

◆ Rast_quant_nof_rules()

int Rast_quant_nof_rules ( const struct Quant q)

Returns the number of quantization rules defined.

This number does not include the 2 infinite intervals.

Parameters
qpointer to Quant structure which holds quant rules info
Returns
number of quantization rules

Definition at line 309 of file quant.c.

References Quant::nofRules.

Referenced by Rast3d_write_cats(), and Rast_get_next_marked_d_cat().

◆ Rast_quant_perform_d()

void Rast_quant_perform_d ( struct Quant q,
const DCELL dcell,
CELL cell,
int  n 
)

Returns in "cell" the quantized CELL values.

Returns in "cell" the quantized CELL values corresponding to the DCELL values stored in "dcell". the number of elements quantized is n. quantization is performed by repeated application of Rast_quant_get_cell_value().

Parameters
qpointer to Quant structure which holds quant rules info
dcellpointer to fp cell values array
[out]cellpointer cell values array
nnumber of cells

Definition at line 715 of file quant.c.

References Rast_is_d_null_value, Rast_quant_get_cell_value(), and Rast_set_c_null_value().

◆ Rast_quant_perform_f()

void Rast_quant_perform_f ( struct Quant q,
const FCELL fcell,
CELL cell,
int  n 
)

Same as Rast_quant_perform_d(), except the type.

Parameters
qpointer to Quant structure which holds quant rules info
fcellpointer to fp cell values array
[out]cellpointer cell values array
nnumber of cells

Definition at line 735 of file quant.c.

References Rast_is_f_null_value, Rast_quant_get_cell_value(), and Rast_set_c_null_value().

◆ Rast_quant_reverse_rule_order()

void Rast_quant_reverse_rule_order ( struct Quant q)

Rreverses the order in which the qunatization rules are stored.

See also Rast_quant_get_ith_rule() and Rast_quant_perform_d()).

Parameters
qpointer to Quant rules which holds quant rules info

Definition at line 513 of file quant.c.

◆ Rast_quant_round()

void Rast_quant_round ( struct Quant quant)

Sets the quant rules to perform simple rounding on floats.

Sets the quant for q rules to perform simple rounding on floats.

Parameters
quantpointer to Quant structure which holds quant rules info

Definition at line 230 of file quant.c.

References Quant::round_only.

Referenced by Rast_round_fp_map().

◆ Rast_quant_set_neg_infinite_rule()

void Rast_quant_set_neg_infinite_rule ( struct Quant q,
DCELL  dLeft,
CELL  c 
)

Defines a rule for values "dLeft" and smaller.

Values in this range are mapped to "c" if none of the "finite" quantization rules applies.

Parameters
qpointer to Quant structure which holds quant rules info
dLeftfp value
cvalue

Definition at line 364 of file quant.c.

Referenced by Rast_set_quant_rules().

◆ Rast_quant_set_pos_infinite_rule()

void Rast_quant_set_pos_infinite_rule ( struct Quant q,
DCELL  dRight,
CELL  c 
)

Defines a rule for values "dRight" and larger.

Values in this range are mapped to "c" if none of the "finite" quantization rules or the negative infinite rule applies.

Parameters
qpointer to Quant structure which holds quant rules info
dRightfp value
cvalue

Definition at line 412 of file quant.c.

Referenced by Rast_set_quant_rules().

◆ Rast_quant_truncate()

void Rast_quant_truncate ( struct Quant quant)

Sets the quant rules to perform simple truncation on floats.

Sets the quant for q rules to perform simple truncation on floats.

Parameters
quantpointer to Quant structure which holds quant rules info

Definition at line 217 of file quant.c.

References Quant::truncate_only.

Referenced by Rast_set_quant_rules(), and Rast_truncate_fp_map().

◆ Rast_quantize_fp_map()

void Rast_quantize_fp_map ( const char *  name,
const char *  mapset,
CELL  min,
CELL  max 
)

Write quant rules (f_quant) for floating-point raster map.

Writes the f_quant file for the raster map name with one rule. The rule is generated using the floating-point range in f_range producing the integer range [cmin,cmax].

Make a rule for map <name> that maps floating range (d_min, d_max) into integer range (min, max) This function is useful when the quant rule doesn't depend of the range of produced float data, for example the slope map would want to have a quant rule: 0.0, 90.0 -> 0 , 90 no matter what the min and max slope of this map is.

Parameters
namemap name
mapsetmapset name
cminminimum value
cmaxmaximum value

Definition at line 81 of file quant_rw.c.

References _, G_fatal_error(), G_fully_qualified_name(), max, min, name, Rast_get_fp_range_min_max(), Rast_is_d_null_value, Rast_quantize_fp_map_range(), and Rast_read_fp_range().

◆ Rast_quantize_fp_map_range()

void Rast_quantize_fp_map_range ( const char *  name,
const char *  mapset,
DCELL  d_min,
DCELL  d_max,
CELL  min,
CELL  max 
)

Write quant rules (f_quant) for floating-point raster map.

Writes the f_quant file for the raster map name with one rule. The rule is generated using the floating-point range [dmin,dmax] and the integer range [min,max]. This routine differs from the one above in that the application controls the floating-point range. For example, r.slope.aspect will use this routine to quantize the slope map from [0.0, 90.0] to [0, 90] even if the range of slopes is not 0-90. The aspect map would be quantized from [0.0, 360.0] to [0, 360].

Make a rule for map <name> that maps floating range (d_min, d_max) into integer range (min, max) This function is useful when the quant rule doesn't depend of the range of produced float data, for example the slope map would want to have a quant rule: 0.0, 90.0 -> 0 , 90 no matter what the min and max slope of this map is.

Parameters
namemap name
mapsetmapset name
d_minminimum fp value
d_maxmaximum fp value
minminimum value
maxmaximum value

Definition at line 124 of file quant_rw.c.

References max, min, name, Rast_quant_add_rule(), Rast_quant_init(), and Rast_write_quant().

Referenced by Rast_quantize_fp_map().

◆ 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_read_cats()

int Rast_read_cats ( const char *  name,
const char *  mapset,
struct Categories pcats 
)

Read raster category file.

The category file for raster map name in mapset is read into the cats structure. If there is an error reading the category file, a diagnostic message is printed and -1 is returned. Otherwise, 0 is returned.

Parameters
nameraster map name
mapsetmapset name
[out]pcatspointer to Cats structure
Returns
-1 on error
0 on success

Definition at line 104 of file raster/cats.c.

◆ Rast_read_color_rule()

int Rast_read_color_rule ( void *  closure,
DCELL  min,
DCELL  max,
DCELL val,
int *  r,
int *  g,
int *  b,
int *  norm,
int *  nval,
int *  dflt 
)

Read color rule.

Parameters
closure
min,maxmin & max values (used only when color rules are in percentage)
valvalue
[out]r,g,bcolor values
norm
nval
dflt
Returns
0 on failure
1 on success

Definition at line 147 of file raster/color_rules.c.

◆ Rast_read_color_rules()

int Rast_read_color_rules ( struct Colors colors,
DCELL  min,
DCELL  max,
read_rule_fn read_rule,
void *  closure 
)

Read color rules from file.

Parameters
[out]colorspointer to Colors structure
min,maxmin & max values (used only when color rules are in percentage)
read_rulepointer to read_rule_fn structure
closure
Returns
0 on failure
1 on success

Definition at line 191 of file raster/color_rules.c.

◆ Rast_read_colors()

int Rast_read_colors ( const char *  name,
const char *  mapset,
struct Colors colors 
)

Read color table of raster map.

The color table for the raster map name in the specified mapset is read into the colors structure. If the data layer has no color table, a default color table is generated and 0 is returned. If there is an error reading the color table, a diagnostic message is printed and -1 is returned. If the color table is read ok, 1 is returned.

This routine reads the rules from the color file. If the input raster map is is a floating-point map it calls Rast_mark_colors_as_fp().

Note: If a secondary color file for map name name exists in the current project, that color file is read. This allows the user to define their own color lookup tables for cell maps found in other mapsets.

Warning message is printed if the color file is missing or invalid.

Parameters
namemap name
mapsetmapset name
[out]colorspointer to Colors structure
Returns
-1 on error
0 if missing, but default colors generated
1 on success

Definition at line 54 of file raster/color_read.c.

◆ Rast_read_fp_range()

int Rast_read_fp_range ( const char *  name,
const char *  mapset,
struct FPRange drange 
)

Read floating-point range.

Read the floating point range file drange. This file is written in binary using XDR format.

An empty range file indicates that the min, max are undefined. This is a valid case, and the result should be an initialized range struct with no defined min/max. If the range file is missing and the map is a floating-point map, this function will create a default range by calling G_construct_default_range().

Parameters
namemap name
mapsetmapset name
drangepointer to FPRange structure which holds fp range
Returns
1 on success
2 range is empty
-1 on error

Definition at line 71 of file raster/range.c.

References _, CELL_TYPE, Range::first_time, G_debug(), G_find_file2_misc(), G_fully_qualified_name(), G_open_old_misc(), G_warning(), G_xdr_get_double(), Range::max, Range::min, name, Rast_init(), Rast_init_fp_range(), Rast_map_type(), Rast_read_range(), Rast_update_fp_range(), and XDR_DOUBLE_NBYTES.

Referenced by Rast_quantize_fp_map(), and Rast_read_range().

◆ Rast_read_histogram()

int Rast_read_histogram ( const char *  name,
const char *  mapset,
struct Histogram histogram 
)

read the histogram information

Reads the histogram information associated with map layer "map" in mapset "mapset" into the structure "histogram".

note: a warning message is printed if the file is missing or incorrect

Parameters
namename of map
mapsetmapset that map belongs to
histogramstruct for histogram
Returns
1 if successful, 0 if no histogram file,

Definition at line 42 of file histogram.c.

References _, count, G_fatal_error(), G_find_file2_misc(), G_fopen_old_misc(), G_warning(), name, NULL, Histogram::num, Rast_extend_histogram(), Rast_init_histogram(), and Rast_sort_histogram().

◆ Rast_read_history()

int Rast_read_history ( const char *  name,
const char *  mapset,
struct History hist 
)

Read raster history file.

This routine reads the history file for the raster map name in mapset into the hist structure.

A diagnostic message is printed and -1 is returned if there is an error reading the history file. Otherwise, 0 is returned.

Parameters
namemap name
mapsetmapset name
histpointer to History structure which holds history info
Returns
-1 on error
0 on success

Definition at line 107 of file raster/history.c.

References _, G_fopen_old(), G_warning(), G_zero(), name, and Rast__read_history().

◆ Rast_read_quant()

int Rast_read_quant ( const char *  name,
const char *  mapset,
struct Quant quant 
)

Reads quantization rules for name in mapset and stores them in the quantization structure. If the map is in another mapset, first checks for quant2 table for this map in current mapset.

Parameters
name
mapset
q
Returns
-2 if raster map is of type integer
-1 if (!G_name_is_fully_qualified())
0 if quantization file does not exist, or the file is empty or has wrong format
1 if non-empty quantization file exists

Definition at line 187 of file quant_rw.c.

References name, Rast__quant_import(), and Rast_quant_init().

Referenced by Rast_read_range().

◆ Rast_read_range()

int Rast_read_range ( const char *  name,
const char *  mapset,
struct Range range 
)

Read raster range (CELL)

This routine reads the range information for the raster map name in mapset into the range structure.

A diagnostic message is printed and -1 is returned if there is an error reading the range file. Otherwise, 0 is returned.

Old range file (those with 4 numbers) should treat zeros in this file as NULL-values. New range files (those with just 2 numbers) should treat these numbers as real data (zeros are real data in this case). An empty range file indicates that the min, max are undefined. This is a valid case, and the result should be an initialized range struct with no defined min/max. If the range file is missing and the map is a floating-point map, this function will create a default range by calling G_construct_default_range().

Parameters
namemap name
mapsetmapset name
[out]rangepointer to Range structure which holds range info
Returns
-1 on error
1 on success
2 if range is empty
3 if raster map is floating-point, get range from quant rules

Definition at line 160 of file raster/range.c.

References _, CELL_TYPE, count, G_find_file2_misc(), G_fopen_old_misc(), G_fully_qualified_name(), G_warning(), name, NULL, Rast_get_fp_range_min_max(), Rast_init_range(), Rast_map_type(), Rast_quant_get_limits(), Rast_quant_is_round(), Rast_quant_is_truncate(), Rast_read_fp_range(), Rast_read_quant(), Rast_update_range(), and x.

Referenced by Rast_get_max_c_cat(), and Rast_read_fp_range().

◆ Rast_read_rstats()

int Rast_read_rstats ( const char *  name,
const char *  mapset,
struct R_stats rstats 
)

Read raster stats.

Read the stats file stats. This file is written in binary using XDR format.

An empty stats file indicates that all cells are NULL. This is a valid case, and the result should be an initialized rstats struct with no defined stats. If the stats file is missing this function will create a default stats with count = 0.

Parameters
namemap name
mapsetmapset name
rstatspointer to R_stats structure which holds raster stats
Returns
1 on success
2 stats is empty
-1 on error or stats file does not exist

Definition at line 276 of file raster/range.c.

References count, Rast_init(), and XDR_DOUBLE_NBYTES.

◆ Rast_read_semantic_label()

char* Rast_read_semantic_label ( const char *  name,
const char *  mapset 
)

Get a raster map semantic label metadata string.

Read raster semantic label metadata file and put string in to str

Parameters
nameraster map name
mapsetmapset name
Returns
string representing semantic label on success
NULL on error

Definition at line 95 of file raster_metadata.c.

Referenced by Rast_get_semantic_label_or_name().

◆ Rast_read_units()

char* Rast_read_units ( const char *  name,
const char *  mapset 
)

Get a raster map's units metadata string.

Read the raster's units metadata file and put string in str

Parameters
nameraster map name
mapsetmapset name
Returns
string representing units on success
NULL on error

Definition at line 37 of file raster_metadata.c.

◆ Rast_read_vdatum()

char* Rast_read_vdatum ( const char *  name,
const char *  mapset 
)

Get a raster map's vertical datum metadata string.

Read the raster's vertical datum metadata file and put string in str

Parameters
nameraster map name
mapsetmapset name
Returns
string representing vertical datum on success
NULL on error

Definition at line 66 of file raster_metadata.c.

◆ Rast_read_vector_cats()

int Rast_read_vector_cats ( const char *  name,
const char *  mapset,
struct Categories pcats 
)

Read vector category file.

Note: This function works with old vector format.

Todo:
: To be moved to the vector library

The category file for vector map name in mapset is read into the cats structure. If there is an error reading the category file, a diagnostic message is printed and -1 is returned. Otherwise, 0 is returned.

Parameters
namevector map name
mapsetmapset name
[out]pcatspointer to Cats structure
Returns
-1 on error
0 on success

Definition at line 140 of file raster/cats.c.

◆ Rast_remove_colors()

int Rast_remove_colors ( const char *  name,
const char *  mapset 
)

Remove color table of raster map.

Parameters
namename of raster map
mapsetname of mapset
Returns
-1 on error
0 color table not found
1 on success

Definition at line 28 of file raster/color_remove.c.

References G_mapset(), G_name_is_fully_qualified(), G_remove(), GMAPSET_MAX, GNAME_MAX, and name.

◆ Rast_remove_histogram()

void Rast_remove_histogram ( const char *  name)

Removes the histogram.

Removes the histogram information associated with map layer "name"

Parameters
namename of map
Returns

Definition at line 333 of file histogram.c.

References G_remove_misc(), and name.

◆ Rast_rewind_cats()

void Rast_rewind_cats ( struct Categories pcats)

Rewind raster categories.

After call to this function Rast_get_next_marked_cat() returns the first marked cat label.

Parameters
pcatspointer to Categories structure

Definition at line 584 of file raster/cats.c.

References Categories::last_marked_rule.

◆ Rast_rewind_cell_stats()

int Rast_rewind_cell_stats ( struct Cell_stats s)

Reset/rewind cell stats.

The structure s is rewound (i.e., positioned at the first raster category) so that sorted sequential retrieval can begin.

Parameters
spointer to Cell_stats structure which holds cell stats info
Returns
0

Definition at line 248 of file cell_stats.c.

Referenced by Rast_make_histogram_cs().

◆ Rast_round_fp_map()

void Rast_round_fp_map ( const char *  name,
const char *  mapset 
)

Writes the quant rules.

Writes the quant rules which indicate that all floating numbers should be rounded instead of applying any quant rules from floats to integers.

Parameters
namemap name
mapsetmapset name

Definition at line 51 of file quant_rw.c.

References name, Rast_quant_init(), Rast_quant_round(), and Rast_write_quant().

◆ Rast_row_repeat_nomask()

int Rast_row_repeat_nomask ( int  fd,
int  row 
)

Loops rows until mismatch?.

This routine works fine if the mask is not set. It may give incorrect results with a mask, since the mask row may have a different repeat value. The issue can be fixed by doing it for the mask as well and using the smaller value.

Parameters
fdfile descriptor
rowstarting row
Returns
number of rows completed

Definition at line 131 of file raster/window_map.c.

References fileinfo::C1, fileinfo::C2, count, R__::fileinfo, R__::rd_window, and Cell_head::rows.

◆ Rast_row_to_northing()

double Rast_row_to_northing ( double  row,
const struct Cell_head window 
)

Row to northing.

Converts a row relative to a window to a northing.

Note: row is a double:

  • row+0.0 will return the northing for the northern edge of the row.
  • row+0.5 will return the northing for the center of the row.
  • row+1.0 will return the northing for the southern edge of the row.
Parameters
rowrow number
[in]windowpointer to Cell_head
Returns
north coordinate

Definition at line 249 of file raster/window.c.

◆ Rast_row_update_fp_range()

void Rast_row_update_fp_range ( const void *  rast,
int  n,
struct FPRange range,
RASTER_MAP_TYPE  data_type 
)

Update range structure based on raster row (floating-point)

This routine updates the range data just like Rast_update_range(), but for n values from the cell array.

Parameters
cellraster values
nnumber of values
rangepointer to Range structure which holds range info
data_typeraster type (CELL, FCELL, DCELL)

Definition at line 635 of file raster/range.c.

References CELL_TYPE, R_stats::count, DCELL_TYPE, FCELL_TYPE, FPRange::first_time, G_incr_void_ptr, FPRange::max, FPRange::min, min, Rast_cell_size(), Rast_is_null_value(), FPRange::rstats, R_stats::sum, and R_stats::sumsq.

◆ Rast_row_update_range()

void Rast_row_update_range ( const CELL cell,
int  n,
struct Range range 
)

Update range structure based on raster row (CELL)

This routine updates the range data just like Rast_update_range(), but for n values from the cell array.

Parameters
cellraster values
nnumber of values
rangepointer to Range structure which holds range info

Definition at line 575 of file raster/range.c.

References Rast__row_update_range().

◆ Rast_set_c_cat()

int Rast_set_c_cat ( const CELL rast1,
const CELL rast2,
const char *  label,
struct Categories pcats 
)

Set a raster category label (CELL)

Adds the label for range rast1 through rast2 in category structure pcats.

Parameters
rast1,rast2raster values (range)
labelcategory label
pcatspointer to Categories structure
Returns
-1 on error
0 if null value detected
1 on success

Definition at line 766 of file raster/cats.c.

References CELL_TYPE, and Rast_set_cat().

◆ Rast_set_c_color()

void Rast_set_c_color ( CELL  cat,
int  r,
int  g,
int  b,
struct Colors colors 
)

Set a category color (CELL)

The red, green, and blue intensities for the color associated with category cat are set in the colors structure. The intensities must be in the range 0 - 255. Values below zero are set as zero, values above 255 are set as 255.

Warning: Use of this routine is discouraged because it defeats the new color logic.

It is provided only for backward compatibility. Overuse can create large color tables. Rast_add_c_color_rule() should be used whenever possible.

Note: The colors structure must have been initialized by G_init_color().

Parameters
catraster cell value
rred value
ggreen value
bblue value
colorspointer to Colors structure which holds color info

Definition at line 41 of file color_set.c.

◆ Rast_set_c_color_range()

void Rast_set_c_color_range ( CELL  min,
CELL  max,
struct Colors colors 
)

Set color range (CELL version)

Parameters
min,maxminimum and maximum value
colorspointer to Colors structure which holds color info

Definition at line 24 of file color_range.c.

◆ Rast_set_c_null_value()

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(), Rast_fpreclass_perform_di(), Rast_fpreclass_perform_fi(), Rast_fpreclass_perform_ii(), 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().

◆ 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_cat()

int Rast_set_cat ( const void *  rast1,
const void *  rast2,
const char *  label,
struct Categories pcats,
RASTER_MAP_TYPE  data_type 
)

Set a raster category label.

Adds the label for range rast1 through rast2 in category structure pcats.

Parameters
rast1,rast2raster values (range)
labelcategory label
pcatspointer to Categories structure
data_typemap type
Returns
-1 on error
0 if null value detected
1 on success

Definition at line 916 of file raster/cats.c.

References Rast_get_d_value(), and Rast_set_d_cat().

Referenced by Rast_set_c_cat(), and Rast_set_f_cat().

◆ Rast_set_cats_fmt()

void Rast_set_cats_fmt ( const char *  fmt,
double  m1,
double  a1,
double  m2,
double  a2,
struct Categories pcats 
)

Set category fmt (?)

Parameters
fmt
m1
a1
m2
a2
pcatspointer to Categories structure

Definition at line 1190 of file raster/cats.c.

◆ Rast_set_cats_title()

void Rast_set_cats_title ( const char *  title,
struct Categories pcats 
)

Set title in category structure.

Todo:
To be removed, replaced by Rast_set_cats_title().

The title is copied into the pcats structure.

Parameters
titletitle
pcatspointer to Categories structure

Definition at line 1171 of file raster/cats.c.

References G_newlines_to_spaces(), G_store(), G_strip(), NULL, and Categories::title.

Referenced by Rast_init_cats().

◆ Rast_set_cell_format()

void Rast_set_cell_format ( int  n)

Sets the format for subsequent opens on new integer cell files (uncompressed and random only).

Warning: subsequent put_row calls will only write n+1 bytes per cell. If the data requires more, the cell file will be written incorrectly (but with n+1 bytes per cell)

When writing float map: format is -1

Parameters
nformat

Definition at line 463 of file raster/open.c.

References R__::nbytes.

◆ Rast_set_d_cat()

int Rast_set_d_cat ( const DCELL rast1,
const DCELL rast2,
const char *  label,
struct Categories pcats 
)

Set a raster category label (DCELL)

Adds the label for range rast1 through rast2 in category structure pcats.

Parameters
rast1,rast2raster values (range)
labelcategory label
pcatspointer to Categories structure
Returns
-1 on error
0 if null value detected
1 on success

Definition at line 804 of file raster/cats.c.

References G_free(), G_malloc, G_newlines_to_spaces(), G_realloc, G_store(), G_strip(), Categories::labels, Categories::marks, Categories::nalloc, Categories::ncats, NULL, Categories::num, Categories::q, Rast_get_ith_d_cat(), Rast_is_d_null_value, and Rast_quant_add_rule().

Referenced by Rast_copy_cats(), and Rast_set_cat().

◆ Rast_set_d_color()

void Rast_set_d_color ( DCELL  val,
int  r,
int  g,
int  b,
struct Colors colors 
)

Set a category color (DCELL)

See Rast_set_c_color() for detailed information.

Parameters
valraster cell value
rred value
ggreen value
bblue value
colorspointer to Colors structure which holds color info

Definition at line 60 of file color_set.c.

◆ Rast_set_d_color_range()

void Rast_set_d_color_range ( DCELL  min,
DCELL  max,
struct Colors colors 
)

Set color range (DCELL version)

Parameters
min,maxminimum and maximum value
colorspointer to Colors structure which holds color info

Definition at line 42 of file color_range.c.

◆ Rast_set_d_null_value()

void Rast_set_d_null_value ( DCELL dcellVals,
int  numVals 
)

◆ 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_default_color()

void Rast_set_default_color ( int  red,
int  grn,
int  blu,
struct Colors colors 
)

Set default color value.

Sets the default color (in colors) to red, green, blue. This is the color for values which do not have an explicit rule.

Parameters
redred value
grngreen value
blublue value
colorspointer to Colors structure which holds color info

Definition at line 99 of file color_set.c.

◆ Rast_set_f_cat()

int Rast_set_f_cat ( const FCELL rast1,
const FCELL rast2,
const char *  label,
struct Categories pcats 
)

Set a raster category label (FCELL)

Adds the label for range rast1 through rast2 in category structure pcats.

Parameters
rast1,rast2raster values (range)
labelcategory label
pcatspointer to Categories structure
Returns

Definition at line 784 of file raster/cats.c.

References FCELL_TYPE, and Rast_set_cat().

◆ Rast_set_f_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(), Rast_fpreclass_perform_df(), Rast_fpreclass_perform_ff(), Rast_fpreclass_perform_if(), Rast_get_f_value(), and Rast_set_null_value().

◆ 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().

◆ Rast_set_fp_type()

void Rast_set_fp_type ( RASTER_MAP_TYPE  map_type)

Set raster map floating-point data format.

This controls the storage type for floating-point maps. It affects subsequent calls to G_open_fp_map_new(). The type must be one of FCELL_TYPE (float) or DCELL_TYPE (double). The use of this routine by applications is discouraged since its use would override user preferences.

Parameters
typeraster data type
Returns
void

Definition at line 833 of file raster/open.c.

References _, DCELL_TYPE, FCELL_TYPE, R__::fp_type, G_fatal_error(), fileinfo::map_type, and Rast__init().

◆ Rast_set_histogram()

int Rast_set_histogram ( CELL  cat,
long  count,
struct Histogram histogram 
)

sets the histogram value for cat to count

sets the histogram value for cat to count

Parameters
catcategory
count
histogramstruct for histogram
Returns
0 if successful, 1 on fail

Definition at line 373 of file histogram.c.

References Histogram::Histogram_list::cat, Histogram::Histogram_list::count, count, Histogram::list, Histogram::num, and Rast_extend_histogram().

◆ Rast_set_history()

void Rast_set_history ( struct History hist,
int  field,
const char *  str 
)

Set the string of a specific history field.

Parameters
histpointer to History structure which holds history info
fieldnumber of a specific history field, should be accessed with macros (HIST_MAPID, ...)
strstring of the history field
Returns
void

Definition at line 193 of file raster/history.c.

References History::fields, G_free(), G_store(), and NULL.

◆ Rast_set_input_window()

void Rast_set_input_window ( struct Cell_head window)

Establishes 'window' as the current working window for input.

Any opened cell files has its file-to-window mapping reworked.

Parameters
windowwindow to become operative window

Definition at line 98 of file raster/set_window.c.

◆ 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 Rast__set_null_value(), Rast_get_vrt_row(), and Rast_set_f_value().

◆ Rast_set_null_value_color()

void Rast_set_null_value_color ( int  red,
int  grn,
int  blu,
struct Colors colors 
)

Set color for NULL-value.

Sets the color (in colors) for the NULL-value to red, green, blue.

Parameters
redred value
grngreen value
blublue value
colorspointer to Colors structure which holds color info

Definition at line 79 of file color_set.c.

◆ Rast_set_output_window()

void Rast_set_output_window ( struct Cell_head window)

Establishes 'window' as the current working window for output.

Parameters
windowwindow to become operative window

Definition at line 76 of file raster/set_window.c.

◆ Rast_set_quant_rules()

void Rast_set_quant_rules ( int  fd,
struct Quant q 
)

Sets quant translation rules for raster map opened for reading.

Returned by Rast_open_old(). After calling this function, Rast_get_c_row() and Rast_get_c_row() will use rules defined by q (instead of using rules defined in map's quant file) to convert floats to ints.

Parameters
fdfile descriptor (cell file)
qpointer to Quant structure
Returns
void

Definition at line 1047 of file raster/open.c.

References _, Quant_table::cHigh, Quant_table::cLow, Quant_table::dHigh, Quant_table::dLow, R__::fileinfo, G_fatal_error(), Quant::nofRules, fileinfo::open_mode, OPEN_OLD, fileinfo::quant, Rast_quant_add_rule(), Rast_quant_get_neg_infinite_rule(), Rast_quant_get_pos_infinite_rule(), Rast_quant_init(), Rast_quant_set_neg_infinite_rule(), Rast_quant_set_pos_infinite_rule(), Rast_quant_truncate(), Quant::table, and Quant::truncate_only.

◆ Rast_set_window()

void Rast_set_window ( struct Cell_head window)

Establishes 'window' as the current working window.

Parameters
windowwindow to become operative window

Definition at line 43 of file raster/set_window.c.

◆ Rast_shift_c_colors()

void Rast_shift_c_colors ( CELL  shift,
struct Colors colors 
)

Definition at line 17 of file color_shift.c.

◆ Rast_shift_d_colors()

void Rast_shift_d_colors ( DCELL  shift,
struct Colors colors 
)

Definition at line 22 of file color_shift.c.

◆ Rast_short_history()

void Rast_short_history ( const char *  name,
const char *  type,
struct History hist 
)

Initialize history structure.

This routine initializes the hist structure, recording the date, user, module name and the raster map name structure. The type can be "raster", "reclass", "GDAL-link", or "virtual".

Note: This routine only initializes the data structure. It does not write the history file.

Parameters
namemap name
typemap type
histpointer to History structure which holds history info

Definition at line 227 of file raster/history.c.

◆ Rast_sort_cats()

int Rast_sort_cats ( struct Categories pcats)

Sort categories.

Parameters
pcatspointer to Categories structure
Returns
-1 on error (nothing to sort)
0 on success

Definition at line 1282 of file raster/cats.c.

References G_debug(), Categories::ncats, and Rast_copy_cats().

◆ Rast_sort_histogram()

int Rast_sort_histogram ( struct Histogram histogram)

Sorts the histogram.

Sorts the histogram in ascending order by category, combining (by adding) elements that have the same category.

Parameters
histogramstruct for histogram
Returns
0 if successful, 1 on fail

Definition at line 219 of file histogram.c.

Referenced by Rast_make_histogram_cs(), and Rast_read_histogram().

◆ Rast_sort_histogram_by_count()

int Rast_sort_histogram_by_count ( struct Histogram histogram)

Sorts the histogram by counts.

Sorts the histogram in ascending order by counts then category. No combining is done.

Parameters
histogramstruct for histogram
Returns
0 if successful, 1 on fail

Definition at line 278 of file histogram.c.

References Histogram::list, list, LIST, and Histogram::num.

◆ Rast_suppress_masking()

void Rast_suppress_masking ( void  )

Suppresses masking.

Returns

Definition at line 84 of file auto_mask.c.

References R__::auto_mask, R__::mask_fd, Rast__init(), and Rast_close().

◆ Rast_truncate_fp_map()

void Rast_truncate_fp_map ( const char *  name,
const char *  mapset 
)

Writes the quant rules.

Writes the quant rules which indicate that all floating numbers should be truncated instead of applying any quant rules from floats to integers.

Parameters
namemap name
mapsetmapset name

Definition at line 31 of file quant_rw.c.

References name, Rast_quant_init(), Rast_quant_truncate(), and Rast_write_quant().

◆ Rast_unmark_cats()

void Rast_unmark_cats ( struct Categories pcats)

Sets marks for all categories to 0.

This initializes Categories structure for subsequent calls to Rast_mark_cats() for each row of data, where non-zero mark for i-th label means that some of the cells in rast_row are labeled with i-th label and fall into i-th data range. These marks help determine from the Categories structure which labels were used and which weren't.

Parameters
pcatspointer to Categories structure

Definition at line 469 of file raster/cats.c.

References Categories::marks, and Categories::ncats.

◆ Rast_unopen()

void Rast_unopen ( int  fd)

Unopen a raster map.

The raster map opened on file descriptor fd is closed. Memory allocated for raster processing is freed. If open for writing, the raster map is not created and the temporary file created when the raster map was opened is removed (see Creating and Opening New Raster Files). This routine is useful when errors are detected and it is desired to not create the new raster map. While it is true that the raster map will not be created if the module exits without closing the file, the temporary file will not be removed at module exit. GRASS database management will eventually remove the temporary file, but the file can be quite large and will take up disk space until GRASS does remove it. Use this routine as a courtesy to the user.

Parameters
fdfile descriptor
Returns
void

Definition at line 132 of file raster/close.c.

References _, R__::fileinfo, R__::fileinfo_count, G_fatal_error(), fileinfo::open_mode, and OPEN_OLD.

Referenced by Rast__check_for_auto_masking(), and Rast_get_vrt_row().

◆ Rast_unset_window()

void Rast_unset_window ( void  )

Unset current window.

Definition at line 64 of file raster/set_window.c.

References G_debug(), and R__::window_set.

◆ Rast_unsuppress_masking()

void Rast_unsuppress_masking ( void  )

Unsuppresses masking.

Returns

Definition at line 102 of file auto_mask.c.

References R__::auto_mask, R__::mask_fd, Rast__check_for_auto_masking(), and Rast__init().

◆ Rast_update_cell_stats()

int Rast_update_cell_stats ( const CELL cell,
int  n,
struct Cell_stats s 
)

Add data to cell stats.

The n CELL values in the data array are inserted (and counted) in the Cell_stats structure.

Look for NULLs and update the NULL-value count.

Parameters
cellraster values
nnumber of values
spointer to Cell_stats structure which holds cell stats info
Returns
1 on failure
0 on success

Definition at line 62 of file cell_stats.c.

◆ Rast_update_fp_range()

void Rast_update_fp_range ( DCELL  val,
struct FPRange range 
)

Update range structure (floating-point)

Compares the cat value with the minimum and maximum values in the range structure, modifying the range if cat extends the range.

NULL-values must be detected and ignored.

Parameters
valraster value
rangepointer to Range structure which holds range info

Definition at line 548 of file raster/range.c.

References FPRange::first_time, FPRange::max, FPRange::min, min, and Rast_is_d_null_value.

Referenced by Rast3d_read_range(), and Rast_read_fp_range().

◆ Rast_update_range()

void Rast_update_range ( CELL  cat,
struct Range range 
)

Update range structure (CELL)

Compares the cat value with the minimum and maximum values in the range structure, modifying the range if cat extends the range.

NULL-values must be detected and ignored.

Parameters
catraster value
rangepointer to Range structure which holds range info

Definition at line 520 of file raster/range.c.

References Range::first_time, Range::max, Range::min, min, and Rast_is_c_null_value.

Referenced by Rast_construct_default_range(), and Rast_read_range().

◆ Rast_want_histogram()

void Rast_want_histogram ( int  flag)

Save histogram for newly create raster map (cell)

If newly created cell files should have histograms, set flag=1 otherwise set flag=0. Applies to subsequent opens.

Parameters
flagflag indicator

Definition at line 446 of file raster/open.c.

References R__::want_histogram.

◆ Rast_window_cols()

int Rast_window_cols ( void  )

Number of columns in active window.

These routines return the number of rows and columns (respectively) in the active module region. Before raster maps can be read or written, it is necessary to known how many rows and columns are in the active region. For example:

int nrows, cols;
int row, col;
nrows = Rast_window_rows();
ncols = Rast_window_cols();
for (row = 0; row < nrows; row++) {
// read row ...
for (col = 0; col < ncols; col++) {
// process col ...
}
}
int Rast_window_cols(void)
Number of columns in active window.
int Rast_window_rows(void)
Number of rows in active window.
Definition: raster/window.c:87
Returns
number of columns

Definition at line 124 of file raster/window.c.

References _, Cell_head::cols, G_fatal_error(), Rast__init_window(), R__::split_window, and R__::wr_window.

Referenced by Rast_allocate_buf(), Rast_allocate_c_buf(), Rast_allocate_d_buf(), Rast_allocate_f_buf(), Rast_allocate_null_buf(), and Rast_zero_buf().

◆ Rast_window_rows()

int Rast_window_rows ( void  )

Number of rows in active window.

This routine returns the number of rows in the active module window. Before raster files can be read or written, it is necessary to known how many rows are in the active window. For example:

int nrows, cols;
int row, col;
nrows = Rast_window_rows();
ncols = Rast_window_cols();
for (row = 0; row < nrows; row++) {
// read row ...
for (col = 0; col < ncols; col++) {
// process col ...
}
}
Returns
number of rows

Definition at line 87 of file raster/window.c.

References _, G_fatal_error(), Rast__init_window(), Cell_head::rows, R__::split_window, and R__::wr_window.

◆ Rast_write_cats()

void Rast_write_cats ( const char *  name,
struct Categories cats 
)

Write raster category file.

Todo:
To be removed, replaced by Rast_write_cats().

Writes the category file for the raster map name in the current mapset from the cats structure.

Parameters
namemap name
catspointer to Categories structure
Returns
void

Definition at line 939 of file raster/cats.c.

◆ Rast_write_colors()

void Rast_write_colors ( const char *  name,
const char *  mapset,
struct Colors colors 
)

Write map layer color table.

The color table is written for the raster map name in the specified mapset from the colors structure.

If there is an error, -1 is returned. No diagnostic is printed. Otherwise, 1 is returned.

The colors structure must be created properly, i.e., Rast_init_colors() to initialize the structure and Rast_add_c_color_rule() to set the category colors. These routines are called by higher level routines which read or create entire color tables, such as Rast_read_colors() or Rast_make_ramp_colors().

Note: The calling sequence for this function deserves special attention. The mapset parameter seems to imply that it is possible to overwrite the color table for a raster map which is in another mapset. However, this is not what actually happens. It is very useful for users to create their own color tables for raster maps in other mapsets, but without overwriting other users' color tables for the same raster map. If mapset is the current mapset, then the color file for name will be overwritten by the new color table. But if mapset is not the current mapset, then the color table is actually written in the current mapset under the colr2 element as: colr2/mapset/name.

The rules are written out using floating-point format, removing trailing zeros (possibly producing integers). The flag marking the colors as floating-point is not written.

If the environment variable FORCE_GRASS3_COLORS is set (to anything at all) then the output format is 3.0, even if the structure contains 4.0 rules. This allows users to create 3.0 color files for export to sites which don't yet have 4.0

Parameters
namemap name
mapsetmapset name
colorspointer to structure Colors which holds color info
Returns
void

Definition at line 72 of file raster/color_write.c.

◆ Rast_write_fp_range()

void Rast_write_fp_range ( const char *  name,
const struct FPRange range 
)

Write raster range file (floating-point)

Write the floating point range file f_range. This file is written in binary using XDR format. If there is no defined min/max in range, an empty f_range file is created.

Parameters
namemap name
rangepointer to FPRange which holds fp range info

Definition at line 409 of file raster/range.c.

References _, FPRange::first_time, G_fatal_error(), G_open_new_misc(), G_remove_misc(), G_xdr_put_double(), FPRange::max, FPRange::min, name, Rast_init(), Rast_write_rstats(), FPRange::rstats, and XDR_DOUBLE_NBYTES.

◆ Rast_write_histogram()

void Rast_write_histogram ( const char *  name,
const struct Histogram histogram 
)

Writes the histogram information.

Writes the histogram information associated with map layer "name"

Parameters
namename of map
histogramstruct for histogram
Returns
void

Definition at line 87 of file histogram.c.

References list, and LIST.

◆ Rast_write_histogram_cs()

void Rast_write_histogram_cs ( const char *  name,
struct Cell_stats statf 
)

Writes the histogram based on cell statistics to file.

Parameters
namename of map
statfcell statistics
Returns
void

Definition at line 112 of file histogram.c.

References count.

◆ Rast_write_history()

void Rast_write_history ( const char *  name,
struct History hist 
)

Write raster history file.

This routine writes the history file for the raster map name in the current mapset from the hist structure.

A diagnostic message is printed and -1 is returned if there is an error writing the history file. Otherwise, 0 is returned.

Note: The hist structure should first be initialized using Rast_short_history().

Parameters
namemap name
[out]histpointer to History structure which holds history info
Returns
void

Definition at line 158 of file raster/history.c.

References _, G_fatal_error(), G_fopen_new(), name, and Rast__write_history().

◆ Rast_write_quant()

void Rast_write_quant ( const char *  name,
const char *  mapset,
const struct Quant quant 
)

Writes the quant rule table for the raster map.

Writes the f_quant file for the raster map name from q. if mapset==G_mapset() i.e. the map is in current mapset, then the original quant file in cell_misc/map/f_quant is written. Otherwise q is written into quant2/mapset/name (much like colr2 element). This results in map@mapset being read using quant rules stored in q from G_mapset(). See Rast_read_quant() for detailes.

Parameters
namemap name
mapsetmapset name
quantpointer to Quant structure which hold quant rules info

Definition at line 150 of file quant_rw.c.

References _, CELL_TYPE, G_fatal_error(), G_warning(), name, Rast__quant_export(), Rast_map_type(), and Rast_quant_get_limits().

Referenced by Rast_quantize_fp_map_range(), Rast_round_fp_map(), and Rast_truncate_fp_map().

◆ Rast_write_range()

void Rast_write_range ( const char *  name,
const struct Range range 
)

Write raster range file.

This routine writes the range information for the raster map name in the current mapset from the range structure. A diagnostic message is printed and -1 is returned if there is an error writing the range file. Otherwise, 0 is returned.

This routine only writes 2 numbers (min,max) to the range file, instead of the 4 (pmin,pmax,nmin,nmax) previously written. If there is no defined min,max, an empty file is written.

Parameters
namemap name
rangepointer to Range structure which holds range info

Definition at line 373 of file raster/range.c.

References _, CELL_TYPE, Range::first_time, G_fatal_error(), G_fopen_new_misc(), G_mapset(), G_remove_misc(), Range::max, Range::min, name, Rast_map_type(), Rast_write_rstats(), and Range::rstats.

◆ Rast_write_rstats()

void Rast_write_rstats ( const char *  name,
const struct R_stats rstats 
)

Write raster stats file.

Write the stats file stats. This file is written in binary using XDR format. If the count is < 1 in rstats, an empty stats file is created.

Parameters
namemap name
rstatspointer to R_stats which holds stats info

Definition at line 451 of file raster/range.c.

References _, R_stats::count, count, G_fatal_error(), G_open_new_misc(), G_remove_misc(), G_xdr_put_double(), name, Rast_init(), FPRange::rstats, R_stats::sum, R_stats::sumsq, and XDR_DOUBLE_NBYTES.

Referenced by Rast_write_fp_range(), and Rast_write_range().

◆ Rast_write_semantic_label()

void Rast_write_semantic_label ( const char *  name,
const char *  str 
)

Write a string into a rasters semantic label metadata file.

Raster map must exist in the current mapset.

It is up to the caller to validate semantic label string in advance with Rast_legal_semantic_label().

Parameters
nameraster map name
strstring containing data to be written

Definition at line 129 of file raster_metadata.c.

◆ Rast_write_units()

void Rast_write_units ( const char *  name,
const char *  str 
)

Write a string to a raster map's units metadata file.

Raster map must exist in the current mapset.

Parameters
nameraster map name
strstring containing data to be written

Definition at line 50 of file raster_metadata.c.

◆ Rast_write_vdatum()

void Rast_write_vdatum ( const char *  name,
const char *  str 
)

Write a string into a raster's vertical datum metadata file.

Raster map must exist in the current mapset.

Parameters
nameraster map name
strstring containing data to be written

Definition at line 79 of file raster_metadata.c.

◆ Rast_write_vector_cats()

void Rast_write_vector_cats ( const char *  name,
struct Categories cats 
)

Write vector category file.

Note: Used for only old vector format!

Todo:
Move to the vector library.
Parameters
namemap name
catspointer to Categories structure
Returns
void

Definition at line 956 of file raster/cats.c.

◆ Rast_zero_buf()

void Rast_zero_buf ( void *  rast,
RASTER_MAP_TYPE  data_type 
)

Zero a raster buffer.

This routines assigns each member of the raster buffer array rast to zero. It assumes that rast has been allocated using Rast_allocate_c_buf().

Parameters
rastdata buffer
data_typeraster type (CELL_TYPE, FCELL_TYPE, DCELL_TYPE)

Definition at line 28 of file zero_cell.c.

References Rast_cell_size(), and Rast_window_cols().

◆ Rast_zero_histogram()

void Rast_zero_histogram ( struct Histogram histogram)

Zero out histogram struct.

Parameters
histogramstruct for histogram
Returns

Definition at line 411 of file histogram.c.

References Histogram::Histogram_list::count, Histogram::list, and Histogram::num.

◆ Rast_zero_input_buf()

void Rast_zero_input_buf ( void *  rast,
RASTER_MAP_TYPE  data_type 
)

Definition at line 33 of file zero_cell.c.

References Rast_cell_size(), and Rast_input_window_cols().

◆ Rast_zero_output_buf()

void Rast_zero_output_buf ( void *  rast,
RASTER_MAP_TYPE  data_type 
)

Definition at line 38 of file zero_cell.c.

References Rast_cell_size(), and Rast_output_window_cols().