GRASS GIS 8 Programmer's Manual
8.5.0dev(2024)-36359e2344
|
Raster Library - Raster cell statistics. More...
Go to the source code of this file.
Macros | |
#define | INCR 10 |
#define | SHIFT 6 |
#define | NODE struct Cell_stats_node |
Functions | |
void | Rast_init_cell_stats (struct Cell_stats *s) |
Initialize cell stats. More... | |
int | Rast_update_cell_stats (const CELL *cell, int n, struct Cell_stats *s) |
Add data to cell stats. More... | |
int | Rast_find_cell_stat (CELL cat, long *count, const struct Cell_stats *s) |
Random query of cell stats. More... | |
int | Rast_rewind_cell_stats (struct Cell_stats *s) |
Reset/rewind cell stats. More... | |
int | Rast_next_cell_stat (CELL *cat, long *count, struct Cell_stats *s) |
Retrieve sorted cell stats. More... | |
void | Rast_get_stats_for_null_value (long *count, const struct Cell_stats *s) |
Get number of null values. More... | |
void | Rast_free_cell_stats (struct Cell_stats *s) |
Free cell stats structure. More... | |
Raster Library - Raster cell statistics.
(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 cell_stats.c.
#define INCR 10 |
Definition at line 19 of file cell_stats.c.
#define NODE struct Cell_stats_node |
Definition at line 24 of file cell_stats.c.
#define SHIFT 6 |
Definition at line 20 of file cell_stats.c.
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.
cat | raster value | |
[out] | count | count |
s | pointer to Cell_stats structure which holds cell stats info |
Definition at line 188 of file cell_stats.c.
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().
s | pointer to Cell_stats structure |
Definition at line 382 of file cell_stats.c.
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.
count | count |
s | pointer to Cell_stats structure which holds cell stats info |
Definition at line 369 of file cell_stats.c.
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.
s | pointer to Cell_stats structure |
Definition at line 39 of file cell_stats.c.
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:
Do not return a record for the NULL-value
cat | raster value | |
[out] | count | |
s | pointer to Cell_stats structure which holds cell stats info |
Definition at line 312 of file cell_stats.c.
Referenced by Rast_make_histogram_cs().
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.
s | pointer to Cell_stats structure which holds cell stats info |
Definition at line 248 of file cell_stats.c.
Referenced by Rast_make_histogram_cs().
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.
cell | raster values |
n | number of values |
s | pointer to Cell_stats structure which holds cell stats info |
Definition at line 62 of file cell_stats.c.