GRASS GIS 7 Programmer's Manual
7.9.dev(2021)-e5379bbd7
|
Raster Library - Raster range file management. More...
Go to the source code of this file.
Macros | |
#define | DEFAULT_CELL_MIN 1 |
#define | DEFAULT_CELL_MAX 255 |
Functions | |
void | Rast__remove_fp_range (const char *name) |
Remove floating-point range. More... | |
void | Rast_construct_default_range (struct Range *range) |
Construct default range. More... | |
int | Rast_read_fp_range (const char *name, const char *mapset, struct FPRange *drange) |
Read floating-point range. More... | |
int | Rast_read_range (const char *name, const char *mapset, struct Range *range) |
Read raster range (CELL) More... | |
int | Rast_read_rstats (const char *name, const char *mapset, struct R_stats *rstats) |
Read raster stats. More... | |
void | Rast_write_range (const char *name, const struct Range *range) |
Write raster range file. More... | |
void | Rast_write_fp_range (const char *name, const struct FPRange *range) |
Write raster range file (floating-point) More... | |
void | Rast_write_rstats (const char *name, const struct R_stats *rstats) |
Write raster stats file. More... | |
void | Rast_update_range (CELL cat, struct Range *range) |
Update range structure (CELL) More... | |
void | Rast_update_fp_range (DCELL val, struct FPRange *range) |
Update range structure (floating-point) More... | |
void | Rast_row_update_range (const CELL *cell, int n, struct Range *range) |
Update range structure based on raster row (CELL) More... | |
void | Rast__row_update_range (const CELL *cell, int n, struct Range *range, int ignore_zeros) |
Update range structure based on raster row. More... | |
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) More... | |
void | Rast_init_range (struct Range *range) |
Initialize range structure. More... | |
void | Rast_get_range_min_max (const struct Range *range, CELL *min, CELL *max) |
Get range min and max. More... | |
void | Rast_init_fp_range (struct FPRange *range) |
Initialize fp range. More... | |
void | Rast_get_fp_range_min_max (const struct FPRange *range, DCELL *min, DCELL *max) |
Get minimum and maximum value from fp range. More... | |
Raster Library - Raster range file management.
(C) 2001-2009 GRASS Development Team
This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.
Definition in file range.c.
#define DEFAULT_CELL_MAX 255 |
Definition at line 22 of file range.c.
Referenced by Rast_construct_default_range().
#define DEFAULT_CELL_MIN 1 |
Definition at line 21 of file range.c.
Referenced by Rast_construct_default_range().
void Rast__remove_fp_range | ( | const char * | name | ) |
Remove floating-point range.
Note: For internal use only.
name | map name |
Definition at line 33 of file range.c.
References G_remove_misc().
Update range structure based on raster row.
Note: for internal use only.
cell | raster values |
n | number of values |
range | pointer to Range structure which holds range info |
ignore_zeros | ignore zeros |
Definition at line 587 of file range.c.
References R_stats::count, Range::first_time, Range::max, min, Range::min, Rast_is_c_null_value, Range::rstats, R_stats::sum, and R_stats::sumsq.
Referenced by Rast_row_update_range().
void Rast_construct_default_range | ( | struct Range * | range | ) |
Construct default range.
Sets the integer range to [1,255]
[out] | r | pointer to Range structure which holds range info |
Definition at line 45 of file range.c.
References DEFAULT_CELL_MAX, DEFAULT_CELL_MIN, and Rast_update_range().
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.
range | pointer to FPRange which holds fp range info | |
[out] | min | minimum value |
[out] | max | maximum value |
Definition at line 764 of file range.c.
References FPRange::first_time, FPRange::max, FPRange::min, Rast_is_d_null_value, and Rast_set_d_null_value().
Referenced by gsd_put_legend(), Rast3d_range_min_max(), Rast_quantize_fp_map(), and Rast_read_range().
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.
range | pointer to Range structure which holds range info | |
[out] | min | minimum value |
[out] | max | maximum value |
Definition at line 714 of file range.c.
References Range::first_time, Range::max, Range::min, Rast_is_c_null_value, and Rast_set_c_null_value().
Referenced by gsd_put_legend(), and Rast_get_max_c_cat().
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.
range | pointer to FPRange which holds fp range info |
Definition at line 742 of file 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().
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.
range | pointer to Range structure which holds range info |
Definition at line 690 of file range.c.
References Range::max, Range::min, and Rast_set_c_null_value().
Referenced by Rast_read_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().
name | map name |
mapset | mapset name |
drange | pointer to FPRange structure which holds fp range |
Definition at line 71 of file 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, Rast_init(), Rast_init_fp_range(), Rast_map_type(), Rast_read_range(), Rast_update_fp_range(), and XDR_DOUBLE_NBYTES.
Referenced by gsd_put_legend(), Rast_quantize_fp_map(), and 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().
name | map name | |
mapset | mapset name | |
[out] | range | pointer to Range structure which holds range info |
Definition at line 160 of file range.c.
References _, CELL_TYPE, count, G_find_file2_misc(), G_fopen_old_misc(), G_fully_qualified_name(), G_warning(), 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 gsd_put_legend(), Rast_get_max_c_cat(), and Rast_read_fp_range().
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.
name | map name |
mapset | mapset name |
rstats | pointer to R_stats structure which holds raster stats |
Definition at line 275 of file range.c.
References count, Rast_init(), and XDR_DOUBLE_NBYTES.
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.
cell | raster values |
n | number of values |
range | pointer to Range structure which holds range info |
data_type | raster type (CELL, FCELL, DCELL) |
Definition at line 630 of file range.c.
References CELL_TYPE, R_stats::count, DCELL_TYPE, FCELL_TYPE, FPRange::first_time, G_incr_void_ptr, FPRange::max, min, FPRange::min, Rast_cell_size(), Rast_is_null_value(), FPRange::rstats, R_stats::sum, and R_stats::sumsq.
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.
cell | raster values |
n | number of values |
range | pointer to Range structure which holds range info |
Definition at line 572 of file range.c.
References Rast__row_update_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.
val | raster value |
range | pointer to Range structure which holds range info |
Definition at line 545 of file range.c.
References FPRange::first_time, FPRange::max, min, FPRange::min, and Rast_is_d_null_value.
Referenced by Rast3d_read_range(), and Rast_read_fp_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.
cat | raster value |
range | pointer to Range structure which holds range info |
Definition at line 517 of file range.c.
References Range::first_time, Range::max, min, Range::min, and Rast_is_c_null_value.
Referenced by Rast_construct_default_range(), and Rast_read_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.
name | map name |
range | pointer to FPRange which holds fp range info |
Definition at line 406 of file range.c.
References _, FPRange::first_time, G_fatal_error(), G_open_new_misc(), G_remove_misc(), G_xdr_put_double(), FPRange::max, FPRange::min, Rast_init(), Rast_write_rstats(), FPRange::rstats, and XDR_DOUBLE_NBYTES.
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.
name | map name |
range | pointer to Range structure which holds range info |
Definition at line 372 of file range.c.
References _, CELL_TYPE, Range::first_time, G_fatal_error(), G_fopen_new_misc(), G_mapset(), G_remove_misc(), Range::max, Range::min, Rast_map_type(), Rast_write_rstats(), and Range::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.
name | map name |
rstats | pointer to R_stats which holds stats info |
Definition at line 448 of file range.c.
References _, count, R_stats::count, G_fatal_error(), G_open_new_misc(), G_remove_misc(), G_xdr_put_double(), Rast_init(), R_stats::sum, R_stats::sumsq, and XDR_DOUBLE_NBYTES.
Referenced by Rast_write_fp_range(), and Rast_write_range().