SAGA API  v9.9
grids.h
Go to the documentation of this file.
1 
3 // //
4 // SAGA //
5 // //
6 // System for Automated Geoscientific Analyses //
7 // //
8 // Application Programming Interface //
9 // //
10 // Library: SAGA_API //
11 // //
12 //-------------------------------------------------------//
13 // //
14 // grids.h //
15 // //
16 // Copyright (C) 2017 by //
17 // Olaf Conrad //
18 // //
19 //-------------------------------------------------------//
20 // //
21 // This file is part of 'SAGA - System for Automated //
22 // Geoscientific Analyses'. //
23 // //
24 // This library is free software; you can redistribute //
25 // it and/or modify it under the terms of the GNU Lesser //
26 // General Public License as published by the Free //
27 // Software Foundation, either version 2.1 of the //
28 // License, or (at your option) any later version. //
29 // //
30 // This library is distributed in the hope that it will //
31 // be useful, but WITHOUT ANY WARRANTY; without even the //
32 // implied warranty of MERCHANTABILITY or FITNESS FOR A //
33 // PARTICULAR PURPOSE. See the GNU Lesser General Public //
34 // License for more details. //
35 // //
36 // You should have received a copy of the GNU Lesser //
37 // General Public License along with this program; if //
38 // not, see <http://www.gnu.org/licenses/>. //
39 // //
40 //-------------------------------------------------------//
41 // //
42 // e-mail: oconrad@saga-gis.org //
43 // //
44 // contact: Olaf Conrad //
45 // Institute of Geography //
46 // University of Hamburg //
47 // Germany //
48 // //
50 
51 //---------------------------------------------------------
52 #ifndef HEADER_INCLUDED__SAGA_API__grids_H
53 #define HEADER_INCLUDED__SAGA_API__grids_H
54 
55 
57 // //
58 // //
59 // //
61 
62 //---------------------------------------------------------
73 // //
75 // //
76 // //
78 
79 //---------------------------------------------------------
80 #include "grid.h"
81 
82 
84 // //
85 // //
86 // //
88 
89 //---------------------------------------------------------
90 typedef enum
91 {
96 }
98 
99 //---------------------------------------------------------
100 #define SG_GRIDS_NAME_OWNER 0x01
101 #define SG_GRIDS_NAME_INDEX 0x02
102 #define SG_GRIDS_NAME_VALUE 0x04
103 #define SG_GRIDS_NAME_GRID 0x08
104 
105 
107 // //
108 // CSG_Grids //
109 // //
111 
112 //---------------------------------------------------------
117 //---------------------------------------------------------
119 {
120 //---------------------------------------------------------
121 public:
122 
123  //-----------------------------------------------------
124  CSG_Grids(void);
125  virtual ~CSG_Grids(void);
126 
127  CSG_Grids (const CSG_Grids &Grids);
128  virtual bool Create (const CSG_Grids &Grids);
129 
130  CSG_Grids (const CSG_Grids *pGrids, bool bCopyData = false);
131  virtual bool Create (const CSG_Grids *pGrids, bool bCopyData = false);
132 
133  CSG_Grids (const char *FileName, bool bLoadData = true);
134  virtual bool Create (const char *FileName, bool bLoadData = true);
135  CSG_Grids (const wchar_t *FileName, bool bLoadData = true);
136  virtual bool Create (const wchar_t *FileName, bool bLoadData = true);
137  CSG_Grids (const CSG_String &FileName, bool bLoadData = true);
138  virtual bool Create (const CSG_String &FileName, bool bLoadData = true);
139 
140  CSG_Grids (const CSG_Grid_System &System, int NZ = 0, double zMin = 0., TSG_Data_Type Type = SG_DATATYPE_Undefined);
141  virtual bool Create (const CSG_Grid_System &System, int NZ = 0, double zMin = 0., TSG_Data_Type Type = SG_DATATYPE_Undefined);
142 
143  CSG_Grids (const CSG_Grid_System &System, const CSG_Table &Attributes, int zAttribute = 0, TSG_Data_Type Type = SG_DATATYPE_Undefined, bool bCreateGrids = false);
144  virtual bool Create (const CSG_Grid_System &System, const CSG_Table &Attributes, int zAttribute = 0, TSG_Data_Type Type = SG_DATATYPE_Undefined, bool bCreateGrids = false);
145 
146  CSG_Grids (int NX, int NY, int NZ = 0, double Cellsize = 0., double xMin = 0., double yMin = 0., double zMin = 0., TSG_Data_Type Type = SG_DATATYPE_Undefined);
147  virtual bool Create (int NX, int NY, int NZ = 0, double Cellsize = 0., double xMin = 0., double yMin = 0., double zMin = 0., TSG_Data_Type Type = SG_DATATYPE_Undefined);
148 
149  CSG_Grids (const CSG_Table &Attributes, int zAttribute = 0);
150  virtual bool Create (const CSG_Table &Attributes, int zAttribute = 0);
151 
152  virtual bool Destroy (void);
153 
154 
155  //-----------------------------------------------------
156  virtual bool Load (const CSG_String &File, bool bLoadData = true);
157 
158  virtual bool Save (const CSG_String &File, int Format = 0);
159  virtual bool Save (const char *File, int Format = 0) { return( Save(CSG_String(File), Format) ); }
160  virtual bool Save (const wchar_t *File, int Format = 0) { return( Save(CSG_String(File), Format) ); }
161 
162 
163  //-----------------------------------------------------
167 
168 
169  //-----------------------------------------------------
170  // Data-Info...
171 
172  TSG_Data_Type Get_Type (void) const { return( m_pGrids[0]->Get_Type() ); }
173 
174  int Get_nValueBytes (void) const { return( m_pGrids[0]->Get_nValueBytes() ); }
175  int Get_nLineBytes (void) const { return( m_pGrids[0]->Get_nLineBytes () ); }
176 
177  void Set_Unit (const CSG_String &Unit);
178  const SG_Char * Get_Unit (void) const { return( m_pGrids[0]->Get_Unit() ); }
179 
180 
181  //-----------------------------------------------------
182  // Georeference...
183 
184  const CSG_Grid_System & Get_System (void) const { return( m_pGrids[0]->Get_System() ); }
185 
186  virtual const CSG_Rect & Get_Extent (void) { return( Get_System().Get_Extent() ); }
187 
188  int Get_NX (void) const { return( m_pGrids[0]->Get_System().Get_NX() ); }
189  int Get_NY (void) const { return( m_pGrids[0]->Get_System().Get_NY() ); }
190  int Get_NZ (void) const { return( (int)m_Attributes.Get_Count() ); }
191  sLong Get_NCells (void) const { return( Get_System().Get_NCells() * Get_NZ() ); }
192  sLong Get_Data_Count (void);
193  sLong Get_NoData_Count (void);
194 
195  double Get_Cellsize (void) const { return( m_pGrids[0]->Get_System().Get_Cellsize() ); }
196  double Get_Cellarea (void) const { return( m_pGrids[0]->Get_System().Get_Cellarea() ); }
197 
198  const CSG_Rect & Get_Extent (bool bCells = false) const { return( m_pGrids[0]->Get_System().Get_Extent(bCells) ); }
199 
200  double Get_XMin (bool bCells = false) const { return( m_pGrids[0]->Get_System().Get_XMin (bCells) ); }
201  double Get_XMax (bool bCells = false) const { return( m_pGrids[0]->Get_System().Get_XMax (bCells) ); }
202  double Get_XRange (bool bCells = false) const { return( m_pGrids[0]->Get_System().Get_XRange(bCells) ); }
203 
204  double Get_YMin (bool bCells = false) const { return( m_pGrids[0]->Get_System().Get_YMin (bCells) ); }
205  double Get_YMax (bool bCells = false) const { return( m_pGrids[0]->Get_System().Get_YMax (bCells) ); }
206  double Get_YRange (bool bCells = false) const { return( m_pGrids[0]->Get_System().Get_YRange(bCells) ); }
207 
208  double Get_ZMin (bool bCells = false) const { return( m_Attributes.Get_Minimum(m_Z_Attribute) ); }
209  double Get_ZMax (bool bCells = false) const { return( m_Attributes.Get_Maximum(m_Z_Attribute) ); }
210  double Get_ZRange (bool bCells = false) const { return( m_Attributes.Get_Range (m_Z_Attribute) ); }
211 
212 
213  //-----------------------------------------------------
214  // Attributes...
215 
216  bool Set_Z_Attribute (int Field, bool bSetNameField = false);
217  int Get_Z_Attribute (void) const { return( m_Z_Attribute ); }
218 
219  bool Set_Z_Name_Field (int Field);
220  int Get_Z_Name_Field (void) const;
221 
222  bool Add_Attribute (const char *Name, TSG_Data_Type Type, int Insert = -1);
223  bool Add_Attribute (const wchar_t *Name, TSG_Data_Type Type, int Insert = -1);
224  bool Add_Attribute (const CSG_String &Name, TSG_Data_Type Type, int Insert = -1);
225  bool Del_Attribute (int Field);
226 
227  const CSG_Table & Get_Attributes (void) const { return( m_Attributes ); }
228  CSG_Table * Get_Attributes_Ptr (void) { return( &m_Attributes ); }
229 
230  CSG_Table_Record & Get_Attributes (int i) const { return( m_Attributes[i] ); }
231 
232  bool Set_Attribute (int i, int Field, const CSG_String &Value);
233  bool Set_Attribute (int i, const CSG_String &Field, const CSG_String &Value);
234  bool Set_Attribute (int i, const wchar_t *Field, const wchar_t *Value);
235  bool Set_Attribute (int i, const char *Field, const char *Value);
236 
237  bool Set_Attribute (int i, int Field, double Value);
238  bool Set_Attribute (int i, const CSG_String &Field, double Value);
239  bool Set_Attribute (int i, const wchar_t *Field, double Value);
240  bool Set_Attribute (int i, const char *Field, double Value);
241 
242  bool Set_Z (int i, double Value);
243  double Get_Z (int i) const { return( m_Attributes[i].asDouble(m_Z_Attribute) ); }
244 
245  bool Update_Z_Order (void);
246 
247 
248  //-----------------------------------------------------
249  // Grids...
250 
251  bool Set_Grid_Count (int Count);
252  int Get_Grid_Count (void) const { return( (int)m_Attributes.Get_Count() ); }
253 
254  bool Add_Grid (double Z);
255  bool Add_Grid (double Z, CSG_Grid *pGrid, bool bAttach = false);
256  bool Add_Grid (CSG_Table_Record &Attributes);
257  bool Add_Grid (CSG_Table_Record &Attributes, CSG_Grid *pGrid, bool bAttach = false);
258 
259  bool Del_Grid (int i, bool bDetach = false);
260  bool Del_Grids ( bool bDetach = false);
261 
262  const CSG_Grid & Get_Grid (int i) const { return( *m_pGrids[i] ); }
263  CSG_Grid * Get_Grid_Ptr (int i) const { return( i >= 0 && i < Get_NZ() ? m_pGrids[i] : NULL ); }
264  CSG_String Get_Grid_Name (int i, int Style = 0) const;
265 
266  sLong Get_Memory_Size (void) const { return( m_pGrids[0]->Get_Memory_Size() * Get_NZ() ); }
267 
268 
269  //-----------------------------------------------------
270  // Values...
271 
272  void Set_Scaling (double Scale = 1., double Offset = 0.);
273  double Get_Scaling (void) const { return( m_pGrids[0]->Get_Scaling() ); }
274  double Get_Offset (void) const { return( m_pGrids[0]->Get_Offset () ); }
275  bool is_Scaled (void) const { return( m_pGrids[0]->is_Scaled () ); }
276 
277  double Get_Mean (void);
278  double Get_Min (void);
279  double Get_Max (void);
280  double Get_Range (void);
281  double Get_StdDev (void);
282  double Get_Variance (void);
283  double Get_Quantile (double Quantile, bool bFromHistogram = true);
284  double Get_Percentile (double Percentile, bool bFromHistogram = true);
285 
286  const CSG_Simple_Statistics & Get_Statistics (void);
287  bool Get_Statistics (const CSG_Rect &rWorld, CSG_Simple_Statistics &Statistics, bool bHoldValues = false) const;
288 
289  const CSG_Histogram & Get_Histogram (size_t nClasses = 0);
290  bool Get_Histogram (const CSG_Rect &rWorld, CSG_Histogram &Histogram, size_t nClasses = 0) const;
291 
292  virtual bool Set_Max_Samples (sLong Max_Samples);
293 
294 
295  //-----------------------------------------------------
296  // Checks...
297 
298  virtual bool is_Valid (void) const;
299 
300  TSG_Intersection is_Intersecting (const CSG_Rect &Extent) const { return( m_pGrids[0]->is_Intersecting(Extent) ); }
301  TSG_Intersection is_Intersecting (const TSG_Rect &Extent) const { return( m_pGrids[0]->is_Intersecting(Extent) ); }
302  TSG_Intersection is_Intersecting (double xMin, double yMin, double xMax, double yMax) const { return( m_pGrids[0]->is_Intersecting(xMin, yMin, xMax, yMax) ); }
303 
304  bool is_Compatible (CSG_Grid *pGrid ) const;
305  bool is_Compatible (CSG_Grids *pGrids) const;
306  bool is_Compatible (const CSG_Grid_System &System) const;
307  bool is_Compatible (int NX, int NY, double Cellsize, double xMin, double yMin) const;
308 
309  bool is_InGrid (int x, int y, int z, bool bCheckNoData = true) const { return( Get_System().is_InGrid(x, y) && z >= 0 && z < Get_NZ() && (!bCheckNoData || !is_NoData(x, y, z)) ); }
310  bool is_InGrid_byPos (double x, double y, double z, bool bCheckNoData = true) const { return( Get_Extent(true).Contains(x, y) && z >= Get_ZMin() && z <= Get_ZMax() && (!bCheckNoData || !is_NoData(Get_System().Get_xWorld_to_Grid(x), Get_System().Get_yWorld_to_Grid(y), (int)z)) ); }
311  bool is_InGrid_byPos (const TSG_Point_3D &p, bool bCheckNoData = true) const { return( is_InGrid_byPos(p.x, p.y, p.z, bCheckNoData) ); }
312 
313 
314  //-----------------------------------------------------
315  // Set update flag when modified...
316 
317  virtual void Set_Modified (bool bModified = true)
318  {
320 
321  m_Attributes.Set_Modified(bModified);
322 
323  if( bModified )
324  {
325  Set_Update_Flag();
326  }
327  }
328 
329  virtual bool is_Modified (void) const
330  {
331  return( CSG_Data_Object::is_Modified() || m_Attributes.is_Modified() );
332  }
333 
334 
335  //-----------------------------------------------------
336  // Operations...
337 
338  void Assign_NoData (void);
339 
340  virtual bool Assign (double Value = 0.);
341  virtual bool Assign (CSG_Data_Object *pObject , bool bProgress = false);
342  virtual bool Assign (CSG_Grids *pGrids, CSG_Grid_Resampling Interpolation, bool bProgress = false);
343 
344 
345  //-----------------------------------------------------
346  // Operators...
347 
348  virtual CSG_Grids & operator = (const CSG_Grids &Grids);
349  virtual CSG_Grids & operator = (double Value );
350 
351  virtual CSG_Grids & operator += (double Value );
352  virtual CSG_Grids & Add (double Value );
353 
354  virtual CSG_Grids & operator -= (double Value );
355  virtual CSG_Grids & Subtract (double Value );
356 
357  virtual CSG_Grids & operator *= (double Value );
358  virtual CSG_Grids & Multiply (double Value );
359 
360  virtual CSG_Grids & operator /= (double Value );
361  virtual CSG_Grids & Divide (double Value );
362 
363  virtual double operator () (int x, int y, int z) const { return( asDouble(x, y, z) ); }
364 
365  virtual CSG_Grid & operator [] (int i) { return( *m_pGrids[i] ); }
366 
367 
368  //-----------------------------------------------------
369  // No Data Value...
370 
371  virtual bool Set_NoData_Value_Range (double loValue, double hiValue);
372 
373  virtual bool is_NoData (int x, int y, int z) const { return( is_NoData_Value(asDouble(x, y, z, false)) ); }
374  virtual bool is_NoData (sLong i) const { return( is_NoData_Value(asDouble( i, false)) ); }
375 
376  virtual void Set_NoData (int x, int y, int z) { Set_Value(x, y, z, Get_NoData_Value(), false); }
377  virtual void Set_NoData (sLong i) { Set_Value( i, Get_NoData_Value(), false); }
378 
379 
380  //-----------------------------------------------------
381  // Get Value...
382 
383  double Get_Value (double x, double y, double z, CSG_Grid_Resampling Resampling = CSG_Grid_Resampling::Bicubic_2, CSG_Grid_Resampling ZResampling = CSG_Grid_Resampling::Undefined) const;
384  double Get_Value (const TSG_Point_3D &p, CSG_Grid_Resampling Resampling = CSG_Grid_Resampling::Bicubic_2, CSG_Grid_Resampling ZResampling = CSG_Grid_Resampling::Undefined) const;
385  bool Get_Value (double x, double y, double z, double &Value, CSG_Grid_Resampling Resampling = CSG_Grid_Resampling::Bicubic_2, CSG_Grid_Resampling ZResampling = CSG_Grid_Resampling::Undefined) const;
386  bool Get_Value (const TSG_Point_3D &p, double &Value, CSG_Grid_Resampling Resampling = CSG_Grid_Resampling::Bicubic_2, CSG_Grid_Resampling ZResampling = CSG_Grid_Resampling::Undefined) const;
387 
388  virtual BYTE asByte (int x, int y, int z, bool bScaled = true) const { return( SG_ROUND_TO_BYTE (asDouble(x, y, z, bScaled)) ); }
389  virtual BYTE asByte (sLong i, bool bScaled = true) const { return( SG_ROUND_TO_BYTE (asDouble( i, bScaled)) ); }
390  virtual char asChar (int x, int y, int z, bool bScaled = true) const { return( SG_ROUND_TO_CHAR (asDouble(x, y, z, bScaled)) ); }
391  virtual char asChar (sLong i, bool bScaled = true) const { return( SG_ROUND_TO_CHAR (asDouble( i, bScaled)) ); }
392  virtual short asShort (int x, int y, int z, bool bScaled = true) const { return( SG_ROUND_TO_SHORT(asDouble(x, y, z, bScaled)) ); }
393  virtual short asShort (sLong i, bool bScaled = true) const { return( SG_ROUND_TO_SHORT(asDouble( i, bScaled)) ); }
394  virtual int asInt (int x, int y, int z, bool bScaled = true) const { return( SG_ROUND_TO_INT (asDouble(x, y, z, bScaled)) ); }
395  virtual int asInt (sLong i, bool bScaled = true) const { return( SG_ROUND_TO_INT (asDouble( i, bScaled)) ); }
396  virtual sLong asLong (int x, int y, int z, bool bScaled = true) const { return( SG_ROUND_TO_SLONG(asDouble(x, y, z, bScaled)) ); }
397  virtual sLong asLong (sLong i, bool bScaled = true) const { return( SG_ROUND_TO_SLONG(asDouble( i, bScaled)) ); }
398  virtual float asFloat (int x, int y, int z, bool bScaled = true) const { return( (float) (asDouble(x, y, z, bScaled)) ); }
399  virtual float asFloat (sLong i, bool bScaled = true) const { return( (float) (asDouble( i, bScaled)) ); }
400 
401  //-----------------------------------------------------
402  virtual double asDouble(sLong i, bool bScaled = true) const
403  {
404  int z = (int)(i / m_pGrids[0]->Get_NCells());
405 
406  return( m_pGrids[z]->asDouble((sLong)(i % m_pGrids[0]->Get_NCells()), bScaled) );
407  }
408 
409  virtual double asDouble(int x, int y, int z, bool bScaled = true) const
410  {
411  return( m_pGrids[z]->asDouble(x, y, bScaled) );
412  }
413 
414 
415  //-----------------------------------------------------
416  // Set Value...
417 
418  virtual void Add_Value(int x, int y, int z, double Value) { Set_Value(x, y, z, asDouble(x, y, z) + Value ); }
419  virtual void Add_Value(sLong i, double Value) { Set_Value( i, asDouble( i) + Value ); }
420 
421  virtual void Mul_Value(int x, int y, int z, double Value) { Set_Value(x, y, z, asDouble(x, y, z) * Value ); }
422  virtual void Mul_Value(sLong i, double Value) { Set_Value( i, asDouble( i) * Value ); }
423 
424  //-----------------------------------------------------
425  virtual void Set_Value(sLong i, double Value, bool bScaled = true)
426  {
427  int z = (int)(i / m_pGrids[0]->Get_NCells());
428 
429  m_pGrids[z]->Set_Value((sLong)(i % m_pGrids[0]->Get_NCells()), Value, bScaled);
430  }
431 
432  virtual void Set_Value(int x, int y, int z, double Value, bool bScaled = true)
433  {
434  m_pGrids[z]->Set_Value(x, y, Value, bScaled);
435  }
436 
437 
438  //-----------------------------------------------------
439  // Index...
440 
441  bool Set_Index (bool bOn = true)
442  {
443  if( !bOn )
444  {
445  SG_FREE_SAFE(m_Index);
446 
447  return( true );
448  }
449 
450  return( _Get_Index() );
451  }
452 
453  sLong Get_Sorted (sLong Position, bool bDown = true, bool bCheckNoData = true)
454  {
455  if( Position >= 0 && Position < Get_NCells() && _Get_Index() )
456  {
457  Position = m_Index[bDown ? Get_NCells() - Position - 1 : Position];
458 
459  if( !bCheckNoData || !is_NoData(Position) )
460  {
461  return( Position );
462  }
463  }
464 
465  return( -1 );
466  }
467 
468  bool Get_Sorted (sLong Position, sLong &i, bool bDown = true, bool bCheckNoData = true)
469  {
470  return( (i = Get_Sorted(Position, bDown, bCheckNoData)) >= 0 );
471  }
472 
473  bool Get_Sorted (sLong Position, int &x, int &y, int &z, bool bDown = true, bool bCheckNoData = true)
474  {
475  if( (Position = Get_Sorted(Position, bDown, bCheckNoData)) >= 0 )
476  {
477  z = (int)(Position / m_pGrids[0]->Get_NCells());
478 
479  Position = Position % m_pGrids[0]->Get_NCells();
480 
481  x = (int)(Position % Get_NX());
482  y = (int)(Position / Get_NX());
483 
484  return( true );
485  }
486 
487  return( false );
488  }
489 
490 
491 //---------------------------------------------------------
492 protected:
493 
494  virtual bool On_Update (void);
495  virtual bool On_Reload (void);
496  virtual bool On_Delete (void);
497 
498 
499 //---------------------------------------------------------
500 private:
501 
502  int m_Z_Attribute, m_Z_Name;
503 
504  sLong *m_Index;
505 
506  CSG_Table m_Attributes;
507 
508  CSG_Array_Pointer m_Grids;
509 
510  CSG_Grid **m_pGrids;
511 
512  CSG_Simple_Statistics m_Statistics;
513 
514  CSG_Histogram m_Histogram;
515 
516 
517  //-----------------------------------------------------
518  void _On_Construction (void);
519 
520  void _Synchronize (CSG_Grid *pGrid);
521 
522  //-----------------------------------------------------
523  bool _Get_Z (double Value, int &iz, double &dz) const;
524 
525  //-----------------------------------------------------
526  bool _Set_Index (void);
527  bool _Get_Index (void)
528  {
529  if( Get_Update_Flag() )
530  {
531  Update();
532  }
533 
534  return( m_Index || _Set_Index() );
535  }
536 
537  //-----------------------------------------------------
538  bool _Load_External (const CSG_String &FileName);
539  bool _Load_PGSQL (const CSG_String &FileName);
540 
541  bool _Load_Normal (const CSG_String &FileName);
542  bool _Save_Normal (const CSG_String &FileName);
543 
544  bool _Load_Compressed (const CSG_String &FileName);
545  bool _Save_Compressed (const CSG_String &FileName);
546 
547  bool _Load_Header (CSG_File &Stream);
548  bool _Save_Header (CSG_File &Stream);
549 
550  bool _Load_Attributes (CSG_File &Stream);
551  bool _Save_Attributes (CSG_File &Stream);
552 
553  bool _Load_Data (CSG_File &Stream, CSG_Grid *pGrid);
554  bool _Save_Data (CSG_File &Stream, CSG_Grid *pGrid);
555 
556  //-----------------------------------------------------
557  bool _Assign_Interpolated (CSG_Grids *pSource, CSG_Grid_Resampling Interpolation);
558  bool _Assign_MeanValue (CSG_Grids *pSource, bool bVolumeProportional);
559  bool _Assign_ExtremeValue (CSG_Grids *pSource, bool bMaximum);
560  bool _Assign_Majority (CSG_Grids *pSource);
561 
562  //-----------------------------------------------------
563  CSG_Grids & _Operation_Arithmetic (const CSG_Grids &Grids, TSG_Grid_Operation Operation);
564  CSG_Grids & _Operation_Arithmetic (double Value , TSG_Grid_Operation Operation);
565 
566 };
567 
568 
570 // //
571 // Functions //
572 // //
574 
575 //---------------------------------------------------------
576 #define SG_GRIDS_PTR_SAFE_SET_NODATA(g, x, y, z) { if( g && g->is_InGrid(x, y, z, false) ) { g->Set_NoData(x, y, z ); } }
577 #define SG_GRIDS_PTR_SAFE_SET_VALUE(g, x, y, z, v) { if( g && g->is_InGrid(x, y, z, false) ) { g->Set_Value (x, y, z, v); } }
578 
579 //---------------------------------------------------------
582 
585 
587 SAGA_API_DLL_EXPORT CSG_Grids * SG_Create_Grids (const CSG_Grids *pGrids, bool bCopyData = false);
588 
590 SAGA_API_DLL_EXPORT CSG_Grids * SG_Create_Grids (const char *FileName, bool bLoadData = true);
592 SAGA_API_DLL_EXPORT CSG_Grids * SG_Create_Grids (const wchar_t *FileName, bool bLoadData = true);
594 SAGA_API_DLL_EXPORT CSG_Grids * SG_Create_Grids (const CSG_String &FileName, bool bLoadData = true);
595 
597 SAGA_API_DLL_EXPORT CSG_Grids * SG_Create_Grids (const CSG_Grid_System &System, int NZ = 0, double zMin = 0., TSG_Data_Type Type = SG_DATATYPE_Undefined);
598 
600 SAGA_API_DLL_EXPORT CSG_Grids * SG_Create_Grids (const CSG_Grid_System &System, const CSG_Table &Attributes, int zAttribute = 0, TSG_Data_Type Type = SG_DATATYPE_Undefined, bool bCreateGrids = false);
601 
603 SAGA_API_DLL_EXPORT CSG_Grids * SG_Create_Grids (int NX, int NY, int NZ = 0, double Cellsize = 0., double xMin = 0., double yMin = 0., double zMin = 0., TSG_Data_Type Type = SG_DATATYPE_Undefined);
604 
606 SAGA_API_DLL_EXPORT CSG_Grids * SG_Create_Grids (const CSG_Table &Attributes, int zAttribute = 0);
607 
608 
610 // //
611 // //
612 // //
614 
615 //---------------------------------------------------------
616 #endif // #ifndef HEADER_INCLUDED__SAGA_API__grids_H
CSG_Grids::asChar
virtual char asChar(sLong i, bool bScaled=true) const
Definition: grids.h:391
CSG_Data_Object::Assign
virtual bool Assign(CSG_Data_Object *pObject, bool bProgress=false)
Definition: dataobject.cpp:797
CSG_Grids::is_InGrid
bool is_InGrid(int x, int y, int z, bool bCheckNoData=true) const
Definition: grids.h:309
CSG_Rect
Definition: geo_tools.h:474
GRIDS_FILE_FORMAT_Normal
@ GRIDS_FILE_FORMAT_Normal
Definition: grids.h:93
CSG_Grids::is_Intersecting
TSG_Intersection is_Intersecting(const CSG_Rect &Extent) const
Definition: grids.h:300
CSG_Grids::Get_NY
int Get_NY(void) const
Definition: grids.h:189
SG_DATATYPE_Undefined
@ SG_DATATYPE_Undefined
Definition: api_core.h:1013
SG_FREE_SAFE
#define SG_FREE_SAFE(PTR)
Definition: api_core.h:205
CSG_Grids::Set_NoData
virtual void Set_NoData(int x, int y, int z)
Definition: grids.h:376
CSG_Grids::asInt
virtual int asInt(int x, int y, int z, bool bScaled=true) const
Definition: grids.h:394
TSG_Intersection
TSG_Intersection
Definition: geo_tools.h:101
CSG_Grids::Get_ZRange
double Get_ZRange(bool bCells=false) const
Definition: grids.h:210
CSG_Grids::is_NoData
virtual bool is_NoData(sLong i) const
Definition: grids.h:374
CSG_Grids::Mul_Value
virtual void Mul_Value(sLong i, double Value)
Definition: grids.h:422
TSG_Grids_File_Format
TSG_Grids_File_Format
Definition: grids.h:91
CSG_Grids::Get_Sorted
sLong Get_Sorted(sLong Position, bool bDown=true, bool bCheckNoData=true)
Definition: grids.h:453
CSG_Grids::Get_Offset
double Get_Offset(void) const
Definition: grids.h:274
CSG_Data_Object::On_Reload
virtual bool On_Reload(void)=0
CSG_Data_Object::On_Delete
virtual bool On_Delete(void)=0
CSG_Grids::Set_Value
virtual void Set_Value(sLong i, double Value, bool bScaled=true)
Definition: grids.h:425
CSG_Data_Object::Update
bool Update(bool bForce=false)
Definition: dataobject.cpp:777
CSG_Grids::is_Intersecting
TSG_Intersection is_Intersecting(double xMin, double yMin, double xMax, double yMax) const
Definition: grids.h:302
SG_ROUND_TO_INT
#define SG_ROUND_TO_INT(x)
Definition: mat_tools.h:155
CSG_Table_Record
Definition: table.h:130
CSG_Grids::Get_Scaling
double Get_Scaling(void) const
Definition: grids.h:273
CSG_Data_Object::Get_NoData_Value
double Get_NoData_Value(bool bUpper=false) const
Definition: dataobject.h:253
CSG_Grids::Get_Attributes
const CSG_Table & Get_Attributes(void) const
Definition: grids.h:227
CSG_Grid_System
Definition: grid.h:220
CSG_Histogram
Definition: mat_tools.h:1013
CSG_Grids::Get_YRange
double Get_YRange(bool bCells=false) const
Definition: grids.h:206
CSG_Grids::Get_Attributes
CSG_Table_Record & Get_Attributes(int i) const
Definition: grids.h:230
CSG_Grids::Get_Grid_Count
int Get_Grid_Count(void) const
Definition: grids.h:252
SSG_Point_3D
Definition: geo_tools.h:265
CSG_Data_Object::is_NoData_Value
bool is_NoData_Value(double Value) const
Definition: dataobject.h:255
CSG_Grids::Get_Extent
virtual const CSG_Rect & Get_Extent(void)
Definition: grids.h:186
CSG_Grids::is_InGrid_byPos
bool is_InGrid_byPos(double x, double y, double z, bool bCheckNoData=true) const
Definition: grids.h:310
CSG_Data_Object::Save
virtual bool Save(const CSG_String &File, int Format=0)=0
CSG_Grids::Add_Value
virtual void Add_Value(sLong i, double Value)
Definition: grids.h:419
grid.h
CSG_Grids::asByte
virtual BYTE asByte(int x, int y, int z, bool bScaled=true) const
Definition: grids.h:388
SSG_Point_3D::x
double x
Definition: geo_tools.h:266
CSG_Grids::Get_NCells
sLong Get_NCells(void) const
Definition: grids.h:191
SG_DATAOBJECT_TYPE_Grids
@ SG_DATAOBJECT_TYPE_Grids
Definition: dataobject.h:119
SG_ROUND_TO_SLONG
#define SG_ROUND_TO_SLONG(x)
Definition: mat_tools.h:158
CSG_Grids::Get_Type
TSG_Data_Type Get_Type(void) const
Definition: grids.h:172
CSG_Grids::Get_Z_Attribute
int Get_Z_Attribute(void) const
Definition: grids.h:217
CSG_Grids::is_Scaled
bool is_Scaled(void) const
Definition: grids.h:275
CSG_Data_Object::Set_Max_Samples
virtual bool Set_Max_Samples(sLong Max_Samples)
Definition: dataobject.cpp:617
CSG_Data_Object::Set_Update_Flag
void Set_Update_Flag(bool bOn=true)
Definition: dataobject.h:285
CSG_Grids::asDouble
virtual double asDouble(int x, int y, int z, bool bScaled=true) const
Definition: grids.h:409
CSG_File
Definition: api_core.h:1129
SSG_Rect
Definition: geo_tools.h:467
GRIDS_FILE_FORMAT_Undefined
@ GRIDS_FILE_FORMAT_Undefined
Definition: grids.h:92
CSG_Grids::Get_YMax
double Get_YMax(bool bCells=false) const
Definition: grids.h:205
CSG_Grids::Get_Unit
const SG_Char * Get_Unit(void) const
Definition: grids.h:178
CSG_Grids::Get_Sorted
bool Get_Sorted(sLong Position, int &x, int &y, int &z, bool bDown=true, bool bCheckNoData=true)
Definition: grids.h:473
CSG_Grids::asLong
virtual sLong asLong(sLong i, bool bScaled=true) const
Definition: grids.h:397
CSG_Grids::Get_NX
int Get_NX(void) const
Definition: grids.h:188
CSG_Grids::asShort
virtual short asShort(sLong i, bool bScaled=true) const
Definition: grids.h:393
CSG_Data_Object
Definition: dataobject.h:180
CSG_Grids::Get_System
const CSG_Grid_System & Get_System(void) const
Definition: grids.h:184
CSG_Grids::Get_nLineBytes
int Get_nLineBytes(void) const
Definition: grids.h:175
CSG_Grids::Get_YMin
double Get_YMin(bool bCells=false) const
Definition: grids.h:204
CSG_Grids::asLong
virtual sLong asLong(int x, int y, int z, bool bScaled=true) const
Definition: grids.h:396
CSG_Grids::asByte
virtual BYTE asByte(sLong i, bool bScaled=true) const
Definition: grids.h:389
CSG_Grids::Get_XRange
double Get_XRange(bool bCells=false) const
Definition: grids.h:202
CSG_Grids::Add_Value
virtual void Add_Value(int x, int y, int z, double Value)
Definition: grids.h:418
CSG_Data_Object::Get_Extent
virtual const CSG_Rect & Get_Extent(void)=0
CSG_Grids::Get_Extent
const CSG_Rect & Get_Extent(bool bCells=false) const
Definition: grids.h:198
CSG_Grids::is_NoData
virtual bool is_NoData(int x, int y, int z) const
Definition: grids.h:373
sLong
signed long long sLong
Definition: api_core.h:158
CSG_Grids::asShort
virtual short asShort(int x, int y, int z, bool bScaled=true) const
Definition: grids.h:392
SG_ROUND_TO_CHAR
#define SG_ROUND_TO_CHAR(x)
Definition: mat_tools.h:151
CSG_Data_Object::On_Update
virtual bool On_Update(void)
Definition: dataobject.h:287
CSG_Grids::Get_Grid_Ptr
CSG_Grid * Get_Grid_Ptr(int i) const
Definition: grids.h:263
GRIDS_FILE_FORMAT_Compressed
@ GRIDS_FILE_FORMAT_Compressed
Definition: grids.h:94
CSG_Data_Object::is_Modified
virtual bool is_Modified(void) const
Definition: dataobject.h:228
CSG_Grids::is_InGrid_byPos
bool is_InGrid_byPos(const TSG_Point_3D &p, bool bCheckNoData=true) const
Definition: grids.h:311
SAGA_API_DLL_EXPORT
#define SAGA_API_DLL_EXPORT
Definition: api_core.h:94
CSG_Data_Object::Set_Modified
virtual void Set_Modified(bool bOn=true)
Definition: dataobject.h:227
SG_ROUND_TO_BYTE
#define SG_ROUND_TO_BYTE(x)
Definition: mat_tools.h:150
CSG_Grids::Get_XMax
double Get_XMax(bool bCells=false) const
Definition: grids.h:201
CSG_Grids::Set_Index
bool Set_Index(bool bOn=true)
Definition: grids.h:441
CSG_Grid_Resampling
CSG_Grid_Resampling
Definition: grid.h:156
CSG_Grids::Get_Memory_Size
sLong Get_Memory_Size(void) const
Definition: grids.h:266
CSG_Grids::Get_ZMax
double Get_ZMax(bool bCells=false) const
Definition: grids.h:209
CSG_Grids::Get_XMin
double Get_XMin(bool bCells=false) const
Definition: grids.h:200
CSG_Table
Definition: table.h:285
CSG_Data_Object::Get_Update_Flag
bool Get_Update_Flag(void)
Definition: dataobject.h:286
CSG_Grids::Save
virtual bool Save(const char *File, int Format=0)
Definition: grids.h:159
CSG_Grids::asFloat
virtual float asFloat(int x, int y, int z, bool bScaled=true) const
Definition: grids.h:398
CSG_Grids::asDouble
virtual double asDouble(sLong i, bool bScaled=true) const
Definition: grids.h:402
SG_Char
#define SG_Char
Definition: api_core.h:536
TSG_Data_Object_Type
TSG_Data_Object_Type
Definition: dataobject.h:117
CSG_String
Definition: api_core.h:563
CSG_Grids::Get_Z
double Get_Z(int i) const
Definition: grids.h:243
CSG_Array_Pointer
Definition: api_core.h:368
CSG_Grids::asFloat
virtual float asFloat(sLong i, bool bScaled=true) const
Definition: grids.h:399
SSG_Point_3D::y
double y
Definition: geo_tools.h:266
CSG_Grids::asChar
virtual char asChar(int x, int y, int z, bool bScaled=true) const
Definition: grids.h:390
CSG_Grids::Save
virtual bool Save(const wchar_t *File, int Format=0)
Definition: grids.h:160
SG_ROUND_TO_SHORT
#define SG_ROUND_TO_SHORT(x)
Definition: mat_tools.h:153
CSG_Grids::Get_Cellarea
double Get_Cellarea(void) const
Definition: grids.h:196
CSG_Grid
Definition: grid.h:501
CSG_Grids::Get_Cellsize
double Get_Cellsize(void) const
Definition: grids.h:195
CSG_Grids::is_Modified
virtual bool is_Modified(void) const
Definition: grids.h:329
SSG_Point_3D::z
double z
Definition: geo_tools.h:266
CSG_Grids::is_Intersecting
TSG_Intersection is_Intersecting(const TSG_Rect &Extent) const
Definition: grids.h:301
SG_Create_Grids
SAGA_API_DLL_EXPORT CSG_Grids * SG_Create_Grids(void)
Definition: grids.cpp:65
CSG_Grids::Set_Modified
virtual void Set_Modified(bool bModified=true)
Definition: grids.h:317
CSG_Grids::Set_NoData
virtual void Set_NoData(sLong i)
Definition: grids.h:377
TSG_Data_Type
TSG_Data_Type
Definition: api_core.h:997
CSG_Grids::Set_Value
virtual void Set_Value(int x, int y, int z, double Value, bool bScaled=true)
Definition: grids.h:432
CSG_Grids::Get_ZMin
double Get_ZMin(bool bCells=false) const
Definition: grids.h:208
CSG_Grids::asInt
virtual int asInt(sLong i, bool bScaled=true) const
Definition: grids.h:395
CSG_Grids::Mul_Value
virtual void Mul_Value(int x, int y, int z, double Value)
Definition: grids.h:421
CSG_Grids
Definition: grids.h:119
CSG_Grids::Get_nValueBytes
int Get_nValueBytes(void) const
Definition: grids.h:174
CSG_Simple_Statistics
Definition: mat_tools.h:725
CSG_Grids::Get_Attributes_Ptr
CSG_Table * Get_Attributes_Ptr(void)
Definition: grids.h:228
CSG_Data_Object::Set_NoData_Value_Range
virtual bool Set_NoData_Value_Range(double Lower, double Upper)
Definition: dataobject.cpp:578
CSG_Data_Object::Destroy
virtual bool Destroy(void)
Definition: dataobject.cpp:281
CSG_Data_Object::is_Valid
virtual bool is_Valid(void) const =0
CSG_Grid_Resampling::NearestNeighbour
@ NearestNeighbour
CSG_Grids::Get_Grid
const CSG_Grid & Get_Grid(int i) const
Definition: grids.h:262
TSG_Grid_Operation
TSG_Grid_Operation
Definition: grid.h:194
CSG_Grids::Get_Sorted
bool Get_Sorted(sLong Position, sLong &i, bool bDown=true, bool bCheckNoData=true)
Definition: grids.h:468
CSG_Grids::Get_ObjectType
virtual TSG_Data_Object_Type Get_ObjectType(void) const
Definition: grids.h:166
CSG_Grids::Get_NZ
int Get_NZ(void) const
Definition: grids.h:190
GRIDS_FILE_FORMAT_GeoTIFF
@ GRIDS_FILE_FORMAT_GeoTIFF
Definition: grids.h:95