GRASS GIS 8 Programmer's Manual  8.4.0dev(2024)-81301443e3
raster.h
Go to the documentation of this file.
1 #ifndef GRASS_RASTER_H
2 #define GRASS_RASTER_H
3 
4 #include <grass/gis.h>
5 
6 /*** defines ***/
7 #define RECLASS_TABLE 1
8 #define RECLASS_RULES 2
9 #define RECLASS_SCALE 3
10 
11 #define CELL_TYPE 0
12 #define FCELL_TYPE 1
13 #define DCELL_TYPE 2
14 
15 /*! \brief Interpolation methods
16 
17  For G_get_raster_sample(), INTERP_TYPE
18  */
19 #define INTERP_UNKNOWN 0
20 #define INTERP_NEAREST 1 /* nearest neighbor interpolation */
21 #define INTERP_BILINEAR 2 /* bilinear interpolation */
22 #define INTERP_BICUBIC 3 /* bicubic interpolation */
23 
24 /*** typedefs ***/
25 typedef int RASTER_MAP_TYPE;
26 
27 /* for G_get_raster_sample() */
28 typedef int INTERP_TYPE;
29 
30 /*** structures ***/
31 struct Reclass {
32  char *name; /* name of raster map being reclassed */
33  char *mapset; /* mapset in which "name" is found */
34  int type; /* type of reclass */
35  int num; /* size of reclass table */
36  CELL min; /* table min */
37  CELL max; /* table max */
38  CELL *table; /* reclass table */
39 };
40 
42  DCELL dLow; /* domain low */
43  DCELL dHigh; /* domain high */
44  DCELL rLow; /* range low */
45  DCELL rHigh; /* range high */
46 };
47 
48 /* reclass structure from double to double used by r.recode to reclass */
49 /* between types: int to double, float to int,... */
50 struct FPReclass {
51  int defaultDRuleSet; /* 1 if default domain rule set */
52  int defaultRRuleSet; /* 1 if default range rule set */
53  int infiniteLeftSet; /* 1 if negative infinite interval rule exists */
54  int infiniteRightSet; /* 1 if positive infinite interval rule exists */
55  int rRangeSet; /* 1 if range range (i.e. interval) is set */
57  int nofRules;
58  DCELL defaultDMin; /* default domain minimum value */
59  DCELL defaultDMax; /* default domain maximum value */
60  DCELL defaultRMin; /* default range minimum value */
61  DCELL defaultRMax; /* default range maximum value */
62  DCELL infiniteDLeft; /* neg infinite rule */
63  DCELL infiniteDRight; /* neg infinite rule */
64  DCELL infiniteRLeft; /* pos infinite rule */
65  DCELL infiniteRRight; /* pos infinite rule */
66  DCELL dMin; /* minimum domain values in rules */
67  DCELL dMax; /* maximum domain values in rules */
68  DCELL rMin; /* minimum range values in rules */
69  DCELL rMax; /* maximum range values in rules */
71 };
72 
73 struct Quant_table {
78 };
79 
80 struct Quant {
87  int cRangeSet;
89  int nofRules;
103 
104  struct {
106 
107  /* pointers to quant rules corresponding to the intervals btwn vals */
108  struct Quant_table **rules;
109  int nalloc;
110  int active;
115  /* all values smaller than inf_dmin become inf_min */
116  /* all values larger than inf_dmax become inf_max */
117  /* inf_min and/or inf_max can be NULL if there are no inf rules */
119 };
120 
121 struct Categories {
122  CELL ncats; /* total number of categories */
123  CELL num; /* the highest cell values. Only exists
124  for backwards compatibility = (CELL)
125  max_fp_values in quant rules */
126  char *title; /* name of data layer */
127  char *fmt; /* printf-like format to generate labels */
128  float m1; /* Multiplication coefficient 1 */
129  float a1; /* Addition coefficient 1 */
130  float m2; /* Multiplication coefficient 2 */
131  float a2; /* Addition coefficient 2 */
132  struct Quant q; /* rules mapping cell values to index in
133  list of labels */
134  char **labels; /* array of labels of size num */
135  int *marks; /* was the value with this label was used? */
136  int nalloc;
138  /* NOTE: to get a rule corresponfing to cats.labels[i], use */
139  /* G_get_ith_c/f/d_raster_cat (pcats, i, val1, val2) */
140  /* it calls */
141  /* G_quant_get_ith_rule(&cats->q, i, val1, val2, &index, &index); */
142  /* and idex ==i, because rule is added at the same time as a */
143  /* label, and quant rules are never reordered. Olga apr,95 */
144 };
145 
146 /*! \brief Raster history info (metadata)
147 
148  See History structure for implementation issues.
149  */
151  /*! \brief Raster name */
153  /*! \brief Raster title */
155  /*! \brief Raster mapset */
157  /*! \brief User who creates raster map */
159  /*! \brief Map type ("raster", "reclass", "GDAL-link", or "virtual") */
161  /*! \brief Description of original data source (two lines) */
164  /*! \brief One-line data description */
166 
167  /*! \brief Number of fields to be defined in History structure */
169 };
170 
171 /*! \brief Raster history info (metadata) */
172 struct History {
173  /*! \brief Array of fields (see \ref History_field for details) */
175  /*! \brief Number of lines in lines array */
176  int nlines;
177  /*! \brief Lines array */
178  char **lines;
179 };
180 
181 struct Cell_stats {
183  int idx;
184  long *count;
185  int left;
186  int right;
187  } *node; /* tree of values */
188 
189  int tlen; /* allocated tree size */
190  int N; /* number of actual nodes in tree */
191  int curp;
194 };
195 
196 struct Histogram {
197  int num;
198 
199  struct Histogram_list {
201  long count;
202  } *list;
203 };
204 
205 struct R_stats {
209 };
210 
211 struct Range {
214  int first_time; /* whether or not range was updated */
215  struct R_stats rstats;
216 };
217 
218 struct FPRange {
221  int first_time; /* whether or not range was updated */
222  struct R_stats rstats;
223 };
224 
225 struct FP_stats {
227  int geom_abs;
228  int flip;
229  int count;
231  unsigned long *stats;
232  unsigned long total;
233 };
234 
235 struct GDAL_link;
236 struct R_vrt;
237 
238 /*** prototypes ***/
239 #include <grass/defs/raster.h>
240 
241 #endif /* GRASS_RASTER_H */
int64_t grass_int64
Definition: gis.h:632
double DCELL
Definition: gis.h:626
int CELL
Definition: gis.h:625
History_field
Raster history info (metadata)
Definition: raster.h:150
@ HIST_NUM_FIELDS
Number of fields to be defined in History structure.
Definition: raster.h:168
@ HIST_KEYWRD
One-line data description.
Definition: raster.h:165
@ HIST_MAPID
Raster name.
Definition: raster.h:152
@ HIST_MAPTYPE
Map type ("raster", "reclass", "GDAL-link", or "virtual")
Definition: raster.h:160
@ HIST_TITLE
Raster title.
Definition: raster.h:154
@ HIST_MAPSET
Raster mapset.
Definition: raster.h:156
@ HIST_CREATOR
User who creates raster map.
Definition: raster.h:158
@ HIST_DATSRC_1
Description of original data source (two lines)
Definition: raster.h:162
@ HIST_DATSRC_2
Definition: raster.h:163
int INTERP_TYPE
Definition: raster.h:28
int RASTER_MAP_TYPE
Definition: raster.h:25
int * marks
Definition: raster.h:135
float a2
Definition: raster.h:131
char ** labels
Definition: raster.h:134
float m2
Definition: raster.h:130
CELL num
Definition: raster.h:123
char * fmt
Definition: raster.h:127
float m1
Definition: raster.h:128
char * title
Definition: raster.h:126
int nalloc
Definition: raster.h:136
float a1
Definition: raster.h:129
CELL ncats
Definition: raster.h:122
int last_marked_rule
Definition: raster.h:137
struct Quant q
Definition: raster.h:132
struct Cell_stats::Cell_stats_node * node
long null_data_count
Definition: raster.h:192
int N
Definition: raster.h:190
int curoffset
Definition: raster.h:193
int tlen
Definition: raster.h:189
int curp
Definition: raster.h:191
struct R_stats rstats
Definition: raster.h:222
DCELL min
Definition: raster.h:219
int first_time
Definition: raster.h:221
DCELL max
Definition: raster.h:220
DCELL dLow
Definition: raster.h:42
DCELL dHigh
Definition: raster.h:43
DCELL rLow
Definition: raster.h:44
DCELL rHigh
Definition: raster.h:45
DCELL defaultDMax
Definition: raster.h:59
int defaultDRuleSet
Definition: raster.h:51
DCELL rMin
Definition: raster.h:68
DCELL dMin
Definition: raster.h:66
struct FPReclass_table * table
Definition: raster.h:70
int nofRules
Definition: raster.h:57
DCELL defaultRMin
Definition: raster.h:60
DCELL dMax
Definition: raster.h:67
int infiniteRightSet
Definition: raster.h:54
int infiniteLeftSet
Definition: raster.h:53
int defaultRRuleSet
Definition: raster.h:52
int maxNofRules
Definition: raster.h:56
DCELL infiniteDRight
Definition: raster.h:63
DCELL infiniteRLeft
Definition: raster.h:64
DCELL defaultRMax
Definition: raster.h:61
DCELL infiniteDLeft
Definition: raster.h:62
DCELL rMax
Definition: raster.h:69
DCELL infiniteRRight
Definition: raster.h:65
int rRangeSet
Definition: raster.h:55
DCELL defaultDMin
Definition: raster.h:58
int geometric
Definition: raster.h:226
int flip
Definition: raster.h:228
DCELL max
Definition: raster.h:230
unsigned long * stats
Definition: raster.h:231
unsigned long total
Definition: raster.h:232
int geom_abs
Definition: raster.h:227
DCELL min
Definition: raster.h:230
int count
Definition: raster.h:229
int num
Definition: raster.h:197
struct Histogram::Histogram_list * list
Raster history info (metadata)
Definition: raster.h:172
int nlines
Number of lines in lines array.
Definition: raster.h:176
char ** lines
Lines array.
Definition: raster.h:178
char * fields[HIST_NUM_FIELDS]
Array of fields (see History_field for details)
Definition: raster.h:174
DCELL dLow
Definition: raster.h:74
CELL cHigh
Definition: raster.h:77
CELL cLow
Definition: raster.h:76
DCELL dHigh
Definition: raster.h:75
Definition: raster.h:80
CELL inf_min
Definition: raster.h:113
DCELL dMin
Definition: raster.h:98
struct Quant_table ** rules
Definition: raster.h:108
int nalloc
Definition: raster.h:109
DCELL inf_dmin
Definition: raster.h:111
int cRangeSet
Definition: raster.h:87
int truncate_only
Definition: raster.h:81
int nofRules
Definition: raster.h:89
struct Quant_table * table
Definition: raster.h:102
int defaultDRuleSet
Definition: raster.h:83
DCELL defaultDMax
Definition: raster.h:91
DCELL * vals
Definition: raster.h:105
int maxNofRules
Definition: raster.h:88
CELL cMin
Definition: raster.h:100
CELL defaultCMin
Definition: raster.h:92
DCELL inf_dmax
Definition: raster.h:112
CELL cMax
Definition: raster.h:101
CELL inf_max
Definition: raster.h:114
DCELL infiniteDLeft
Definition: raster.h:94
DCELL infiniteDRight
Definition: raster.h:95
int round_only
Definition: raster.h:82
int infiniteRightSet
Definition: raster.h:86
int defaultCRuleSet
Definition: raster.h:84
CELL infiniteCLeft
Definition: raster.h:96
CELL infiniteCRight
Definition: raster.h:97
int infiniteLeftSet
Definition: raster.h:85
CELL defaultCMax
Definition: raster.h:93
struct Quant::@5 fp_lookup
DCELL dMax
Definition: raster.h:99
DCELL defaultDMin
Definition: raster.h:90
int active
Definition: raster.h:110
DCELL sumsq
Definition: raster.h:207
grass_int64 count
Definition: raster.h:208
DCELL sum
Definition: raster.h:206
Definition: R.h:46
Definition: raster.h:211
CELL min
Definition: raster.h:212
int first_time
Definition: raster.h:214
CELL max
Definition: raster.h:213
struct R_stats rstats
Definition: raster.h:215
Definition: raster.h:31
int num
Definition: raster.h:35
CELL * table
Definition: raster.h:38
char * mapset
Definition: raster.h:33
CELL max
Definition: raster.h:37
char * name
Definition: raster.h:32
int type
Definition: raster.h:34
CELL min
Definition: raster.h:36