GRASS Programmer's Manual
6.4.1(2011)
|
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
#include <grass/glocale.h>
Go to the source code of this file.
Functions | |
int | G_read_cats (const char *name, const char *mapset, struct Categories *pcats) |
read raster category file | |
int | G_read_raster_cats (const char *name, const char *mapset, struct Categories *pcats) |
Is the same as existing G_read_cats() | |
int | G_read_vector_cats (const char *name, const char *mapset, struct Categories *pcats) |
read vector category file | |
CELL | G_number_of_cats (const char *name, const char *mapset) |
CELL | G__read_cats (const char *element, const char *name, const char *mapset, struct Categories *pcats, int full) |
char * | G_get_cats_title (const struct Categories *pcats) |
get title from category structure struct | |
char * | G_get_raster_cats_title (const struct Categories *pcats) |
get raster cats title | |
char * | G_get_cat (CELL num, struct Categories *pcats) |
get a category label | |
char * | G_get_c_raster_cat (CELL *rast, struct Categories *pcats) |
given a CELL value val Returns pointer to a string describing category. | |
char * | G_get_f_raster_cat (FCELL *rast, struct Categories *pcats) |
given a FCELL value val Returns pointer to a string describing category. | |
char * | G_get_d_raster_cat (DCELL *rast, struct Categories *pcats) |
given a DCELL value val Returns pointer to a string describing category. | |
char * | G_get_raster_cat (void *rast, struct Categories *pcats, RASTER_MAP_TYPE data_type) |
given a raster value val of type data_type Returns pointer to a string describing category. | |
int | G_unmark_raster_cats (struct Categories *pcats) |
Sets marks for all categories to 0. This initializes Categories structure for subsequest calls to G_mark_raster_cats (rast_row,...) 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. | |
int | G_mark_c_raster_cats (CELL *rast_row, int ncols, struct Categories *pcats) |
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. | |
int | G_mark_f_raster_cats (FCELL *rast_row, int ncols, struct Categories *pcats) |
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. | |
int | G_mark_d_raster_cats (DCELL *rast_row, int ncols, struct Categories *pcats) |
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. | |
int | G_mark_raster_cats (void *rast_row, int ncols, struct Categories *pcats, RASTER_MAP_TYPE data_type) |
Looks up the category label for each raster value in the rast_row (row of raster cell value) 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. | |
int | G_rewind_raster_cats (struct Categories *pcats) |
after call to this function G_get_next_marked_raster_cat() returns the first marked cat label. | |
char * | G_get_next_marked_d_raster_cat (struct Categories *pcats, DCELL *rast1, DCELL *rast2, long *count) |
char * | G_get_next_marked_c_raster_cat (struct Categories *pcats, CELL *rast1, CELL *rast2, long *count) |
char * | G_get_next_marked_f_raster_cat (struct Categories *pcats, FCELL *rast1, FCELL *rast2, long *count) |
char * | G_get_next_marked_raster_cat (struct Categories *pcats, void *rast1, void *rast2, long *count, RASTER_MAP_TYPE data_type) |
int | G_set_cat (CELL num, char *label, struct Categories *pcats) |
set a category label | |
int | G_set_c_raster_cat (CELL *rast1, CELL *rast2, char *label, struct Categories *pcats) |
Adds the label for range rast1 through rast2 in category structure pcats. | |
int | G_set_f_raster_cat (FCELL *rast1, FCELL *rast2, char *label, struct Categories *pcats) |
Adds the label for range rast1 through rast2 in category structure pcats. | |
int | G_set_d_raster_cat (DCELL *rast1, DCELL *rast2, char *label, struct Categories *pcats) |
Adds the label for range rast1 through rast2 in category structure pcats. | |
int | G_set_raster_cat (void *rast1, void *rast2, char *label, struct Categories *pcats, RASTER_MAP_TYPE data_type) |
Adds the label for range rast1 through rast2 in category structure pcats. | |
int | G_write_cats (char *name, struct Categories *cats) |
write raster category file | |
int | G_write_raster_cats (char *name, struct Categories *cats) |
Same as existing G_write_cats() | |
int | G_write_vector_cats (char *name, struct Categories *cats) |
write vector category file | |
int | G__write_cats (char *element, char *name, struct Categories *cats) |
char * | G_get_ith_d_raster_cat (const struct Categories *pcats, int i, DCELL *rast1, DCELL *rast2) |
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. | |
char * | G_get_ith_f_raster_cat (const struct Categories *pcats, int i, void *rast1, void *rast2) |
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. | |
char * | G_get_ith_c_raster_cat (const struct Categories *pcats, int i, void *rast1, void *rast2) |
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. | |
char * | G_get_ith_raster_cat (const struct Categories *pcats, int i, void *rast1, void *rast2, RASTER_MAP_TYPE data_type) |
Returns i-th description and i-th data range from the list of category descriptions with corresponding data ranges. Stores end points of data interval in rast1 and rast2 (after converting them to data_type. | |
int | G_init_cats (CELL num, const char *title, struct Categories *pcats) |
initialize category structure | |
int | G_init_raster_cats (const char *title, struct Categories *pcats) |
Same as existing G_init_raster_cats() only ncats argument is missign. ncats has no meaning in new Categories structure and only stores (int) largets data value for backwards compatibility. | |
int | G_set_cats_title (const char *title, struct Categories *pcats) |
set title in category structure | |
int | G_set_raster_cats_title (const char *title, struct Categories *pcats) |
Same as existing G_set_cats_title() | |
int | G_set_cats_fmt (const char *fmt, double m1, double a1, double m2, double a2, struct Categories *pcats) |
int | G_set_raster_cats_fmt (const char *fmt, double m1, double a1, double m2, double a2, struct Categories *pcats) |
Same as existing G_set_cats_fmt() | |
int | G_free_cats (struct Categories *pcats) |
free category structure memory | |
int | G_free_raster_cats (struct Categories *pcats) |
Same as existing G_free_cats() | |
int | G_copy_raster_cats (struct Categories *pcats_to, const struct Categories *pcats_from) |
Allocates NEW space for quant rules and labels n pcats_to and copies all info from pcats_from cats to pcats_to cats. returns: 0 if successful. | |
int | G_number_of_raster_cats (struct Categories *pcats) |
int | G_sort_cats (struct Categories *pcats) |
CELL G__read_cats | ( | const char * | element, |
const char * | name, | ||
const char * | mapset, | ||
struct Categories * | pcats, | ||
int | full | ||
) |
Definition at line 436 of file cats.c.
References G_fopen_old(), G_getl(), G_init_raster_cats(), G_raster_map_is_fp(), G_set_cat(), G_set_raster_cat(), G_set_raster_cats_fmt(), and G_strip().
Referenced by G_read_raster_cats(), and G_read_vector_cats().
int G__write_cats | ( | char * | element, |
char * | name, | ||
struct Categories * | cats | ||
) |
Definition at line 1226 of file cats.c.
References G_fopen_new(), G_get_ith_d_raster_cat(), G_mapset(), G_quant_nof_rules(), G_raster_map_is_fp(), G_sort_cats(), G_trim_decimal(), and NULL.
Referenced by G_write_cats(), G_write_raster_cats(), and G_write_vector_cats().
int G_copy_raster_cats | ( | struct Categories * | pcats_to, |
const struct Categories * | pcats_from | ||
) |
Allocates NEW space for quant rules and labels n pcats_to and copies all info from pcats_from cats to pcats_to cats. returns: 0 if successful.
-1 on fail
pcats_to | |
pcats_from |
Definition at line 1598 of file cats.c.
References G_get_ith_d_raster_cat(), G_init_raster_cats(), and G_set_d_raster_cat().
Referenced by G_sort_cats().
int G_free_cats | ( | struct Categories * | pcats | ) |
free category structure memory
Frees memory allocated byG_read_cats, G_init_cats andG_set_cat.
cats |
Definition at line 1540 of file cats.c.
References G_free_raster_cats().
int G_free_raster_cats | ( | struct Categories * | pcats | ) |
Same as existing G_free_cats()
pcats |
Definition at line 1556 of file cats.c.
References G_free(), G_quant_free(), and NULL.
Referenced by G_free_cats(), and G_sort_cats().
char* G_get_c_raster_cat | ( | CELL * | rast, |
struct Categories * | pcats | ||
) |
given a CELL value val Returns pointer to a string describing category.
val | |
pcats |
Definition at line 600 of file cats.c.
References G_get_raster_cat().
Referenced by G_get_cat().
char* G_get_cat | ( | CELL | num, |
struct Categories * | pcats | ||
) |
get a category label
This routine looks up category n in the cats 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 cats, then a pointer to the empty string "" is returned. Warning. The pointer that is returned points to a hidden static buffer. Successive calls to G_get_cat( ) overwrite this buffer.
n | |
cats |
Definition at line 583 of file cats.c.
References G_get_c_raster_cat().
Referenced by G_get_raster_sample_bilinear(), G_get_raster_sample_cubic(), and G_get_raster_sample_nearest().
char* G_get_cats_title | ( | const struct Categories * | pcats | ) |
get title from category structure struct
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.
cats |
Definition at line 545 of file cats.c.
References G_get_raster_cats_title().
char* G_get_d_raster_cat | ( | DCELL * | rast, |
struct Categories * | pcats | ||
) |
given a DCELL value val Returns pointer to a string describing category.
val | |
pcats |
Definition at line 634 of file cats.c.
References G_get_raster_cat().
char* G_get_f_raster_cat | ( | FCELL * | rast, |
struct Categories * | pcats | ||
) |
given a FCELL value val Returns pointer to a string describing category.
val | |
pcats |
Definition at line 617 of file cats.c.
References G_get_raster_cat().
char* G_get_ith_c_raster_cat | ( | const struct Categories * | pcats, |
int | i, | ||
void * | rast1, | ||
void * | rast2 | ||
) |
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.
pcats | |
i | |
rast1 | |
rast2 |
Definition at line 1355 of file cats.c.
References G_get_ith_d_raster_cat(), and G_set_raster_value_d().
char* G_get_ith_d_raster_cat | ( | const struct Categories * | pcats, |
int | i, | ||
DCELL * | rast1, | ||
DCELL * | rast2 | ||
) |
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.
pcats | |
i | |
rast1 | |
rast2 |
Definition at line 1298 of file cats.c.
References G_quant_get_ith_rule(), and G_set_d_null_value().
Referenced by G__write_cats(), G_copy_raster_cats(), G_get_ith_c_raster_cat(), G_get_ith_f_raster_cat(), G_get_ith_raster_cat(), G_get_next_marked_d_raster_cat(), G_set_d_raster_cat(), and G_sort_cats().
char* G_get_ith_f_raster_cat | ( | const struct Categories * | pcats, |
int | i, | ||
void * | rast1, | ||
void * | rast2 | ||
) |
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.
pcats | |
i | |
rast1 | |
rast2 |
Definition at line 1327 of file cats.c.
References G_get_ith_d_raster_cat(), and G_set_raster_value_d().
char* G_get_ith_raster_cat | ( | const struct Categories * | pcats, |
int | i, | ||
void * | rast1, | ||
void * | rast2, | ||
RASTER_MAP_TYPE | data_type | ||
) |
Returns i-th description and i-th data range from the list of category descriptions with corresponding data ranges. Stores end points of data interval in rast1 and rast2 (after converting them to data_type.
pcats | |
i | |
rast1 | |
rast2 | |
data_type |
Definition at line 1385 of file cats.c.
References G_get_ith_d_raster_cat(), and G_set_raster_value_d().
char* G_get_next_marked_c_raster_cat | ( | struct Categories * | pcats, |
CELL * | rast1, | ||
CELL * | rast2, | ||
long * | count | ||
) |
Definition at line 890 of file cats.c.
References G_get_next_marked_raster_cat().
char* G_get_next_marked_d_raster_cat | ( | struct Categories * | pcats, |
DCELL * | rast1, | ||
DCELL * | rast2, | ||
long * | count | ||
) |
Definition at line 860 of file cats.c.
References G_get_ith_d_raster_cat(), G_quant_nof_rules(), and NULL.
Referenced by G_get_next_marked_raster_cat().
char* G_get_next_marked_f_raster_cat | ( | struct Categories * | pcats, |
FCELL * | rast1, | ||
FCELL * | rast2, | ||
long * | count | ||
) |
Definition at line 898 of file cats.c.
References G_get_next_marked_raster_cat().
char* G_get_next_marked_raster_cat | ( | struct Categories * | pcats, |
void * | rast1, | ||
void * | rast2, | ||
long * | count, | ||
RASTER_MAP_TYPE | data_type | ||
) |
Definition at line 906 of file cats.c.
References G_get_next_marked_d_raster_cat(), and G_set_raster_value_d().
Referenced by G_get_next_marked_c_raster_cat(), and G_get_next_marked_f_raster_cat().
char* G_get_raster_cat | ( | void * | rast, |
struct Categories * | pcats, | ||
RASTER_MAP_TYPE | data_type | ||
) |
given a raster value val of type data_type Returns pointer to a string describing category.
val | |
pcats | |
data_type |
Definition at line 652 of file cats.c.
References G_debug(), G_get_raster_value_d(), G_is_c_null_value(), G_is_null_value(), G_quant_get_cell_value(), and NULL.
Referenced by G_get_c_raster_cat(), G_get_d_raster_cat(), and G_get_f_raster_cat().
char* G_get_raster_cats_title | ( | const struct Categories * | pcats | ) |
get raster cats title
Returns pointer to a string with title.
pcats |
Definition at line 560 of file cats.c.
Referenced by G_get_cats_title().
int G_init_cats | ( | CELL | num, |
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; G_init_cats ( (CELL)0, "", &cats);
n | |
title | |
cats |
Definition at line 1417 of file cats.c.
References G_init_raster_cats().
int G_init_raster_cats | ( | const char * | title, |
struct Categories * | pcats | ||
) |
Same as existing G_init_raster_cats() only ncats argument is missign. ncats has no meaning in new Categories structure and only stores (int) largets data value for backwards compatibility.
title | |
pcats |
Definition at line 1437 of file cats.c.
References G_quant_init(), G_set_raster_cats_title(), and NULL.
Referenced by G__read_cats(), G_copy_raster_cats(), G_init_cats(), and G_sort_cats().
int G_mark_c_raster_cats | ( | CELL * | rast_row, |
int | ncols, | ||
struct Categories * | pcats | ||
) |
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.
rast_row | |
ncols | |
pcats |
Definition at line 755 of file cats.c.
References G_mark_raster_cats().
int G_mark_d_raster_cats | ( | DCELL * | rast_row, |
int | ncols, | ||
struct Categories * | pcats | ||
) |
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.
rast_row | |
ncols | |
pcats |
Definition at line 799 of file cats.c.
References G_mark_raster_cats().
int G_mark_f_raster_cats | ( | FCELL * | rast_row, |
int | ncols, | ||
struct Categories * | pcats | ||
) |
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.
rast_row | |
ncols | |
pcats |
Definition at line 777 of file cats.c.
References G_mark_raster_cats().
int G_mark_raster_cats | ( | void * | rast_row, |
int | ncols, | ||
struct Categories * | pcats, | ||
RASTER_MAP_TYPE | data_type | ||
) |
Looks up the category label for each raster value in the rast_row (row of raster cell value) 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.
rast_row | |
ncols | |
pcats | |
data_type |
Definition at line 823 of file cats.c.
References G_get_raster_value_d(), G_incr_void_ptr(), G_is_c_null_value(), G_quant_get_cell_value(), and G_raster_size().
Referenced by G_mark_c_raster_cats(), G_mark_d_raster_cats(), and G_mark_f_raster_cats().
CELL G_number_of_cats | ( | const char * | name, |
const char * | mapset | ||
) |
Definition at line 422 of file cats.c.
References G_get_range_min_max(), G_is_c_null_value(), and G_read_range().
int G_number_of_raster_cats | ( | struct Categories * | pcats | ) |
int G_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.
name | |
mapset | |
cats |
Definition at line 347 of file cats.c.
References G_read_raster_cats().
int G_read_raster_cats | ( | const char * | name, |
const char * | mapset, | ||
struct Categories * | pcats | ||
) |
Is the same as existing G_read_cats()
name | |
mapset | |
pcats |
Definition at line 365 of file cats.c.
References G__read_cats(), and G_warning().
Referenced by G_read_cats().
int G_read_vector_cats | ( | const char * | name, |
const char * | mapset, | ||
struct Categories * | pcats | ||
) |
read vector category file
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.
name | |
mapset | |
cats |
Definition at line 401 of file cats.c.
References G__read_cats(), and G_warning().
int G_rewind_raster_cats | ( | struct Categories * | pcats | ) |
after call to this function G_get_next_marked_raster_cat() returns the first marked cat label.
pcats |
int G_set_c_raster_cat | ( | CELL * | rast1, |
CELL * | rast2, | ||
char * | label, | ||
struct Categories * | pcats | ||
) |
Adds the label for range rast1 through rast2 in category structure pcats.
rast1 | |
rast2 | |
pcats |
Definition at line 1021 of file cats.c.
References G_set_raster_cat().
Referenced by G_set_cat().
int G_set_cat | ( | CELL | num, |
char * | label, | ||
struct Categories * | pcats | ||
) |
set a category label
The label is copied into the cats structure for category n.
n | |
label | |
cats |
Definition at line 1001 of file cats.c.
References G_set_c_raster_cat().
Referenced by G__read_cats().
int G_set_cats_fmt | ( | const char * | fmt, |
double | m1, | ||
double | a1, | ||
double | m2, | ||
double | a2, | ||
struct Categories * | pcats | ||
) |
Definition at line 1493 of file cats.c.
References G_set_raster_cats_fmt().
int G_set_cats_title | ( | const char * | title, |
struct Categories * | pcats | ||
) |
set title in category structure
The title is copied into the cats structure.
title | |
cats |
Definition at line 1466 of file cats.c.
References G_set_raster_cats_title().
int G_set_d_raster_cat | ( | DCELL * | rast1, |
DCELL * | rast2, | ||
char * | label, | ||
struct Categories * | pcats | ||
) |
Adds the label for range rast1 through rast2 in category structure pcats.
rast1 | |
rast2 | |
pcats |
Definition at line 1059 of file cats.c.
References G_free(), G_get_ith_d_raster_cat(), G_is_d_null_value(), G_newlines_to_spaces(), G_quant_add_rule(), G_store(), G_strip(), and NULL.
Referenced by G_copy_raster_cats(), G_set_raster_cat(), and G_sort_cats().
int G_set_f_raster_cat | ( | FCELL * | rast1, |
FCELL * | rast2, | ||
char * | label, | ||
struct Categories * | pcats | ||
) |
Adds the label for range rast1 through rast2 in category structure pcats.
rast1 | |
rast2 | |
pcats |
Definition at line 1040 of file cats.c.
References G_set_raster_cat().
int G_set_raster_cat | ( | void * | rast1, |
void * | rast2, | ||
char * | label, | ||
struct Categories * | pcats, | ||
RASTER_MAP_TYPE | data_type | ||
) |
Adds the label for range rast1 through rast2 in category structure pcats.
rast1 | |
rast2 | |
pcats | |
data_type |
Definition at line 1160 of file cats.c.
References G_get_raster_value_d(), and G_set_d_raster_cat().
Referenced by G__read_cats(), G_set_c_raster_cat(), and G_set_f_raster_cat().
int G_set_raster_cats_fmt | ( | const char * | fmt, |
double | m1, | ||
double | a1, | ||
double | m2, | ||
double | a2, | ||
struct Categories * | pcats | ||
) |
Same as existing G_set_cats_fmt()
fmt | |
m1 | |
a1 | |
m2 | |
a2 | |
pcats |
Definition at line 1515 of file cats.c.
References G_newlines_to_spaces(), G_store(), and G_strip().
Referenced by G__read_cats(), and G_set_cats_fmt().
int G_set_raster_cats_title | ( | const char * | title, |
struct Categories * | pcats | ||
) |
Same as existing G_set_cats_title()
title | |
pcats |
Definition at line 1483 of file cats.c.
References G_newlines_to_spaces(), G_store(), G_strip(), and NULL.
Referenced by G_init_raster_cats(), and G_set_cats_title().
int G_sort_cats | ( | struct Categories * | pcats | ) |
Definition at line 1620 of file cats.c.
References G_copy_raster_cats(), G_free_raster_cats(), G_get_ith_d_raster_cat(), G_init_raster_cats(), and G_set_d_raster_cat().
Referenced by G__write_cats().
int G_unmark_raster_cats | ( | struct Categories * | pcats | ) |
Sets marks for all categories to 0. This initializes Categories structure for subsequest calls to G_mark_raster_cats (rast_row,...) 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.
pcats |
int G_write_cats | ( | char * | name, |
struct Categories * | cats | ||
) |
write raster category file
Writes the category file for the raster map name in the current mapset from the cats structure. Returns 1 if successful. Otherwise, -1 is returned (no diagnostic is printed).
name | |
cats |
Definition at line 1185 of file cats.c.
References G__write_cats().
int G_write_raster_cats | ( | char * | name, |
struct Categories * | cats | ||
) |
Same as existing G_write_cats()
name | |
pcats |
Definition at line 1201 of file cats.c.
References G__write_cats().
int G_write_vector_cats | ( | char * | name, |
struct Categories * | cats | ||
) |
write vector category file
Writes the category file for the vector map name in the current mapset from the cats structure. Returns 1 if successful. Otherwise, -1 is returned (no diagnostic is printed).
name | |
cats |
Definition at line 1221 of file cats.c.
References G__write_cats().