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