SAGA API  v9.6
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 // CSG_Grids //
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  virtual bool Destroy (void);
150 
151 
152  //-----------------------------------------------------
153  virtual bool Load (const CSG_String &File, bool bLoadData = true);
154 
155  virtual bool Save (const CSG_String &File, int Format = 0);
156  virtual bool Save (const char *File, int Format = 0) { return( Save(CSG_String(File), Format) ); }
157  virtual bool Save (const wchar_t *File, int Format = 0) { return( Save(CSG_String(File), Format) ); }
158 
159 
160  //-----------------------------------------------------
164 
165 
166  //-----------------------------------------------------
167  // Data-Info...
168 
169  TSG_Data_Type Get_Type (void) const { return( m_pGrids[0]->Get_Type() ); }
170 
171  int Get_nValueBytes (void) const { return( m_pGrids[0]->Get_nValueBytes() ); }
172  int Get_nLineBytes (void) const { return( m_pGrids[0]->Get_nLineBytes () ); }
173 
174  void Set_Unit (const CSG_String &Unit);
175  const SG_Char * Get_Unit (void) const { return( m_pGrids[0]->Get_Unit() ); }
176 
177 
178  //-----------------------------------------------------
179  // Georeference...
180 
181  const CSG_Grid_System & Get_System (void) const { return( m_pGrids[0]->Get_System() ); }
182 
183  virtual const CSG_Rect & Get_Extent (void) { return( Get_System().Get_Extent() ); }
184 
185  int Get_NX (void) const { return( m_pGrids[0]->Get_System().Get_NX() ); }
186  int Get_NY (void) const { return( m_pGrids[0]->Get_System().Get_NY() ); }
187  int Get_NZ (void) const { return( (int)m_Attributes.Get_Count() ); }
188  sLong Get_NCells (void) const { return( Get_System().Get_NCells() * Get_NZ() ); }
189  sLong Get_Data_Count (void);
190  sLong Get_NoData_Count (void);
191 
192  double Get_Cellsize (void) const { return( m_pGrids[0]->Get_System().Get_Cellsize() ); }
193  double Get_Cellarea (void) const { return( m_pGrids[0]->Get_System().Get_Cellarea() ); }
194 
195  const CSG_Rect & Get_Extent (bool bCells = false) const { return( m_pGrids[0]->Get_System().Get_Extent(bCells) ); }
196 
197  double Get_XMin (bool bCells = false) const { return( m_pGrids[0]->Get_System().Get_XMin (bCells) ); }
198  double Get_XMax (bool bCells = false) const { return( m_pGrids[0]->Get_System().Get_XMax (bCells) ); }
199  double Get_XRange (bool bCells = false) const { return( m_pGrids[0]->Get_System().Get_XRange(bCells) ); }
200 
201  double Get_YMin (bool bCells = false) const { return( m_pGrids[0]->Get_System().Get_YMin (bCells) ); }
202  double Get_YMax (bool bCells = false) const { return( m_pGrids[0]->Get_System().Get_YMax (bCells) ); }
203  double Get_YRange (bool bCells = false) const { return( m_pGrids[0]->Get_System().Get_YRange(bCells) ); }
204 
205  double Get_ZMin (bool bCells = false) const { return( m_Attributes.Get_Minimum(m_Z_Attribute) ); }
206  double Get_ZMax (bool bCells = false) const { return( m_Attributes.Get_Maximum(m_Z_Attribute) ); }
207  double Get_ZRange (bool bCells = false) const { return( m_Attributes.Get_Range (m_Z_Attribute) ); }
208 
209 
210  //-----------------------------------------------------
211  // Attributes...
212 
213  bool Set_Z_Attribute (int Field);
214  int Get_Z_Attribute (void) const { return( m_Z_Attribute ); }
215 
216  bool Set_Z_Name_Field (int Field);
217  int Get_Z_Name_Field (void) const;
218 
219  bool Add_Attribute (const char *Name, TSG_Data_Type Type, int Insert = -1);
220  bool Add_Attribute (const wchar_t *Name, TSG_Data_Type Type, int Insert = -1);
221  bool Add_Attribute (const CSG_String &Name, TSG_Data_Type Type, int Insert = -1);
222  bool Del_Attribute (int Field);
223 
224  const CSG_Table & Get_Attributes (void) const { return( m_Attributes ); }
225  CSG_Table * Get_Attributes_Ptr (void) { return( &m_Attributes ); }
226 
227  CSG_Table_Record & Get_Attributes (int i) const { return( m_Attributes[i] ); }
228 
229  bool Set_Attribute (int i, int Field, const CSG_String &Value);
230  bool Set_Attribute (int i, const CSG_String &Field, const CSG_String &Value);
231  bool Set_Attribute (int i, const wchar_t *Field, const wchar_t *Value);
232  bool Set_Attribute (int i, const char *Field, const char *Value);
233 
234  bool Set_Attribute (int i, int Field, double Value);
235  bool Set_Attribute (int i, const CSG_String &Field, double Value);
236  bool Set_Attribute (int i, const wchar_t *Field, double Value);
237  bool Set_Attribute (int i, const char *Field, double Value);
238 
239  bool Set_Z (int i, double Value);
240  double Get_Z (int i) const { return( m_Attributes[i].asDouble(m_Z_Attribute) ); }
241 
242  bool Update_Z_Order (void);
243 
244 
245  //-----------------------------------------------------
246  // Grids...
247 
248  bool Set_Grid_Count (int Count);
249  int Get_Grid_Count (void) const { return( (int)m_Attributes.Get_Count() ); }
250 
251  bool Add_Grid (double Z);
252  bool Add_Grid (double Z, CSG_Grid *pGrid, bool bAttach = false);
253  bool Add_Grid (CSG_Table_Record &Attributes);
254  bool Add_Grid (CSG_Table_Record &Attributes, CSG_Grid *pGrid, bool bAttach = false);
255 
256  bool Del_Grid (int i, bool bDetach = false);
257  bool Del_Grids ( bool bDetach = false);
258 
259  const CSG_Grid & Get_Grid (int i) const { return( *m_pGrids[i] ); }
260  CSG_Grid * Get_Grid_Ptr (int i) const { return( m_pGrids[i] ); }
261  CSG_String Get_Grid_Name (int i, int Style = 0) const;
262 
263  sLong Get_Memory_Size (void) const { return( m_pGrids[0]->Get_Memory_Size() * Get_NZ() ); }
264 
265 
266  //-----------------------------------------------------
267  // Values...
268 
269  void Set_Scaling (double Scale = 1., double Offset = 0.);
270  double Get_Scaling (void) const { return( m_pGrids[0]->Get_Scaling() ); }
271  double Get_Offset (void) const { return( m_pGrids[0]->Get_Offset () ); }
272  bool is_Scaled (void) const { return( m_pGrids[0]->is_Scaled () ); }
273 
274  double Get_Mean (void);
275  double Get_Min (void);
276  double Get_Max (void);
277  double Get_Range (void);
278  double Get_StdDev (void);
279  double Get_Variance (void);
280  double Get_Quantile (double Quantile, bool bFromHistogram = true);
281  double Get_Percentile (double Percentile, bool bFromHistogram = true);
282 
283  const CSG_Simple_Statistics & Get_Statistics (void);
284  bool Get_Statistics (const CSG_Rect &rWorld, CSG_Simple_Statistics &Statistics, bool bHoldValues = false) const;
285 
286  const CSG_Histogram & Get_Histogram (size_t nClasses = 0);
287  bool Get_Histogram (const CSG_Rect &rWorld, CSG_Histogram &Histogram, size_t nClasses = 0) const;
288 
289  virtual bool Set_Max_Samples (sLong Max_Samples);
290 
291 
292  //-----------------------------------------------------
293  // Checks...
294 
295  virtual bool is_Valid (void) const;
296 
297  TSG_Intersection is_Intersecting (const CSG_Rect &Extent) const { return( m_pGrids[0]->is_Intersecting(Extent) ); }
298  TSG_Intersection is_Intersecting (const TSG_Rect &Extent) const { return( m_pGrids[0]->is_Intersecting(Extent) ); }
299  TSG_Intersection is_Intersecting (double xMin, double yMin, double xMax, double yMax) const { return( m_pGrids[0]->is_Intersecting(xMin, yMin, xMax, yMax) ); }
300 
301  bool is_Compatible (CSG_Grid *pGrid ) const;
302  bool is_Compatible (CSG_Grids *pGrids) const;
303  bool is_Compatible (const CSG_Grid_System &System) const;
304  bool is_Compatible (int NX, int NY, double Cellsize, double xMin, double yMin) const;
305 
306  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)) ); }
307  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)) ); }
308  bool is_InGrid_byPos (const TSG_Point_3D &p, bool bCheckNoData = true) const { return( is_InGrid_byPos(p.x, p.y, p.z, bCheckNoData) ); }
309 
310 
311  //-----------------------------------------------------
312  // Set update flag when modified...
313 
314  virtual void Set_Modified (bool bModified = true)
315  {
317 
318  m_Attributes.Set_Modified(bModified);
319 
320  if( bModified )
321  {
322  Set_Update_Flag();
323  }
324  }
325 
326  virtual bool is_Modified (void) const
327  {
328  return( CSG_Data_Object::is_Modified() || m_Attributes.is_Modified() );
329  }
330 
331 
332  //-----------------------------------------------------
333  // Operations...
334 
335  void Assign_NoData (void);
336 
337  virtual bool Assign (double Value = 0.);
338  virtual bool Assign (CSG_Data_Object *pObject);
339  virtual bool Assign (CSG_Grids *pGrids, TSG_Grid_Resampling Interpolation);
340 
341 
342  //-----------------------------------------------------
343  // Operators...
344 
345  virtual CSG_Grids & operator = (const CSG_Grids &Grids);
346  virtual CSG_Grids & operator = (double Value );
347 
348  virtual CSG_Grids & operator += (double Value );
349  virtual CSG_Grids & Add (double Value );
350 
351  virtual CSG_Grids & operator -= (double Value );
352  virtual CSG_Grids & Subtract (double Value );
353 
354  virtual CSG_Grids & operator *= (double Value );
355  virtual CSG_Grids & Multiply (double Value );
356 
357  virtual CSG_Grids & operator /= (double Value );
358  virtual CSG_Grids & Divide (double Value );
359 
360  virtual double operator () (int x, int y, int z) const { return( asDouble(x, y, z) ); }
361 
362  virtual CSG_Grid & operator [] (int i) { return( *m_pGrids[i] ); }
363 
364 
365  //-----------------------------------------------------
366  // No Data Value...
367 
368  virtual bool Set_NoData_Value_Range (double loValue, double hiValue);
369 
370  virtual bool is_NoData (int x, int y, int z) const { return( is_NoData_Value(asDouble(x, y, z, false)) ); }
371  virtual bool is_NoData (sLong i) const { return( is_NoData_Value(asDouble( i, false)) ); }
372 
373  virtual void Set_NoData (int x, int y, int z) { Set_Value(x, y, z, Get_NoData_Value(), false); }
374  virtual void Set_NoData (sLong i) { Set_Value( i, Get_NoData_Value(), false); }
375 
376 
377  //-----------------------------------------------------
378  // Get Value...
379 
380  double Get_Value (double x, double y, double z, TSG_Grid_Resampling Resampling = GRID_RESAMPLING_BSpline, TSG_Grid_Resampling ZResampling = GRID_RESAMPLING_Undefined) const;
381  double Get_Value (const TSG_Point_3D &p, TSG_Grid_Resampling Resampling = GRID_RESAMPLING_BSpline, TSG_Grid_Resampling ZResampling = GRID_RESAMPLING_Undefined) const;
382  bool Get_Value (double x, double y, double z, double &Value, TSG_Grid_Resampling Resampling = GRID_RESAMPLING_BSpline, TSG_Grid_Resampling ZResampling = GRID_RESAMPLING_Undefined) const;
383  bool Get_Value (const TSG_Point_3D &p, double &Value, TSG_Grid_Resampling Resampling = GRID_RESAMPLING_BSpline, TSG_Grid_Resampling ZResampling = GRID_RESAMPLING_Undefined) const;
384 
385  virtual BYTE asByte (int x, int y, int z, bool bScaled = true) const { return( SG_ROUND_TO_BYTE (asDouble(x, y, z, bScaled)) ); }
386  virtual BYTE asByte (sLong i, bool bScaled = true) const { return( SG_ROUND_TO_BYTE (asDouble( i, bScaled)) ); }
387  virtual char asChar (int x, int y, int z, bool bScaled = true) const { return( SG_ROUND_TO_CHAR (asDouble(x, y, z, bScaled)) ); }
388  virtual char asChar (sLong i, bool bScaled = true) const { return( SG_ROUND_TO_CHAR (asDouble( i, bScaled)) ); }
389  virtual short asShort (int x, int y, int z, bool bScaled = true) const { return( SG_ROUND_TO_SHORT(asDouble(x, y, z, bScaled)) ); }
390  virtual short asShort (sLong i, bool bScaled = true) const { return( SG_ROUND_TO_SHORT(asDouble( i, bScaled)) ); }
391  virtual int asInt (int x, int y, int z, bool bScaled = true) const { return( SG_ROUND_TO_INT (asDouble(x, y, z, bScaled)) ); }
392  virtual int asInt (sLong i, bool bScaled = true) const { return( SG_ROUND_TO_INT (asDouble( i, bScaled)) ); }
393  virtual sLong asLong (int x, int y, int z, bool bScaled = true) const { return( SG_ROUND_TO_SLONG(asDouble(x, y, z, bScaled)) ); }
394  virtual sLong asLong (sLong i, bool bScaled = true) const { return( SG_ROUND_TO_SLONG(asDouble( i, bScaled)) ); }
395  virtual float asFloat (int x, int y, int z, bool bScaled = true) const { return( (float) (asDouble(x, y, z, bScaled)) ); }
396  virtual float asFloat (sLong i, bool bScaled = true) const { return( (float) (asDouble( i, bScaled)) ); }
397 
398  //-----------------------------------------------------
399  virtual double asDouble(sLong i, bool bScaled = true) const
400  {
401  int z = (int)(i / m_pGrids[0]->Get_NCells());
402 
403  return( m_pGrids[z]->asDouble((sLong)(i % m_pGrids[0]->Get_NCells()), bScaled) );
404  }
405 
406  virtual double asDouble(int x, int y, int z, bool bScaled = true) const
407  {
408  return( m_pGrids[z]->asDouble(x, y, bScaled) );
409  }
410 
411 
412  //-----------------------------------------------------
413  // Set Value...
414 
415  virtual void Add_Value(int x, int y, int z, double Value) { Set_Value(x, y, z, asDouble(x, y, z) + Value ); }
416  virtual void Add_Value(sLong i, double Value) { Set_Value( i, asDouble( i) + Value ); }
417 
418  virtual void Mul_Value(int x, int y, int z, double Value) { Set_Value(x, y, z, asDouble(x, y, z) * Value ); }
419  virtual void Mul_Value(sLong i, double Value) { Set_Value( i, asDouble( i) * Value ); }
420 
421  //-----------------------------------------------------
422  virtual void Set_Value(sLong i, double Value, bool bScaled = true)
423  {
424  int z = (int)(i / m_pGrids[0]->Get_NCells());
425 
426  m_pGrids[z]->Set_Value((sLong)(i % m_pGrids[0]->Get_NCells()), Value, bScaled);
427  }
428 
429  virtual void Set_Value(int x, int y, int z, double Value, bool bScaled = true)
430  {
431  m_pGrids[z]->Set_Value(x, y, Value, bScaled);
432  }
433 
434 
435  //-----------------------------------------------------
436  // Index...
437 
438  bool Set_Index (bool bOn = true)
439  {
440  if( !bOn )
441  {
442  SG_FREE_SAFE(m_Index);
443 
444  return( true );
445  }
446 
447  return( _Get_Index() );
448  }
449 
450  sLong Get_Sorted (sLong Position, bool bDown = true, bool bCheckNoData = true)
451  {
452  if( Position >= 0 && Position < Get_NCells() && _Get_Index() )
453  {
454  Position = m_Index[bDown ? Get_NCells() - Position - 1 : Position];
455 
456  if( !bCheckNoData || !is_NoData(Position) )
457  {
458  return( Position );
459  }
460  }
461 
462  return( -1 );
463  }
464 
465  bool Get_Sorted (sLong Position, sLong &i, bool bDown = true, bool bCheckNoData = true)
466  {
467  return( (i = Get_Sorted(Position, bDown, bCheckNoData)) >= 0 );
468  }
469 
470  bool Get_Sorted (sLong Position, int &x, int &y, int &z, bool bDown = true, bool bCheckNoData = true)
471  {
472  if( (Position = Get_Sorted(Position, bDown, bCheckNoData)) >= 0 )
473  {
474  z = (int)(Position / m_pGrids[0]->Get_NCells());
475 
476  Position = Position % m_pGrids[0]->Get_NCells();
477 
478  x = (int)(Position % Get_NX());
479  y = (int)(Position / Get_NX());
480 
481  return( true );
482  }
483 
484  return( false );
485  }
486 
487 
488 //---------------------------------------------------------
489 protected:
490 
491  virtual bool On_Update (void);
492  virtual bool On_Reload (void);
493  virtual bool On_Delete (void);
494 
495 
496 //---------------------------------------------------------
497 private:
498 
499  int m_Z_Attribute, m_Z_Name;
500 
501  sLong *m_Index;
502 
503  CSG_Table m_Attributes;
504 
505  CSG_Array_Pointer m_Grids;
506 
507  CSG_Grid **m_pGrids;
508 
509  CSG_Simple_Statistics m_Statistics;
510 
511  CSG_Histogram m_Histogram;
512 
513 
514  //-----------------------------------------------------
515  void _On_Construction (void);
516 
517  void _Synchronize (CSG_Grid *pGrid);
518 
519  //-----------------------------------------------------
520  bool _Get_Z (double Value, int &iz, double &dz) const;
521 
522  //-----------------------------------------------------
523  bool _Set_Index (void);
524  bool _Get_Index (void)
525  {
526  if( Get_Update_Flag() )
527  {
528  Update();
529  }
530 
531  return( m_Index || _Set_Index() );
532  }
533 
534  //-----------------------------------------------------
535  bool _Load_External (const CSG_String &FileName);
536  bool _Load_PGSQL (const CSG_String &FileName);
537 
538  bool _Load_Normal (const CSG_String &FileName);
539  bool _Save_Normal (const CSG_String &FileName);
540 
541  bool _Load_Compressed (const CSG_String &FileName);
542  bool _Save_Compressed (const CSG_String &FileName);
543 
544  bool _Load_Header (CSG_File &Stream);
545  bool _Save_Header (CSG_File &Stream);
546 
547  bool _Load_Attributes (CSG_File &Stream);
548  bool _Save_Attributes (CSG_File &Stream);
549 
550  bool _Load_Data (CSG_File &Stream, CSG_Grid *pGrid);
551  bool _Save_Data (CSG_File &Stream, CSG_Grid *pGrid);
552 
553  //-----------------------------------------------------
554  bool _Assign_Interpolated (CSG_Grids *pSource, TSG_Grid_Resampling Interpolation);
555  bool _Assign_MeanValue (CSG_Grids *pSource, bool bVolumeProportional);
556  bool _Assign_ExtremeValue (CSG_Grids *pSource, bool bMaximum);
557  bool _Assign_Majority (CSG_Grids *pSource);
558 
559  //-----------------------------------------------------
560  CSG_Grids & _Operation_Arithmetic (const CSG_Grids &Grids, TSG_Grid_Operation Operation);
561  CSG_Grids & _Operation_Arithmetic (double Value , TSG_Grid_Operation Operation);
562 
563 };
564 
565 
567 // //
568 // Functions //
569 // //
571 
572 //---------------------------------------------------------
573 #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 ); } }
574 #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); } }
575 
576 //---------------------------------------------------------
579 
582 
584 SAGA_API_DLL_EXPORT CSG_Grids * SG_Create_Grids (const CSG_Grids *pGrids, bool bCopyData = false);
585 
587 SAGA_API_DLL_EXPORT CSG_Grids * SG_Create_Grids (const char *FileName, bool bLoadData = true);
589 SAGA_API_DLL_EXPORT CSG_Grids * SG_Create_Grids (const wchar_t *FileName, bool bLoadData = true);
591 SAGA_API_DLL_EXPORT CSG_Grids * SG_Create_Grids (const CSG_String &FileName, bool bLoadData = true);
592 
594 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);
595 
597 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);
598 
600 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);
601 
602 
604 // //
605 // //
606 // //
608 
609 //---------------------------------------------------------
610 #endif // #ifndef HEADER_INCLUDED__SAGA_API__grids_H
CSG_Grids::asChar
virtual char asChar(sLong i, bool bScaled=true) const
Definition: grids.h:388
CSG_Grids::is_InGrid
bool is_InGrid(int x, int y, int z, bool bCheckNoData=true) const
Definition: grids.h:306
CSG_Rect
Definition: geo_tools.h:471
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:297
CSG_Grids::Get_NY
int Get_NY(void) const
Definition: grids.h:186
CSG_Data_Object::Assign
virtual bool Assign(CSG_Data_Object *pObject)
Definition: dataobject.cpp:793
SG_DATATYPE_Undefined
@ SG_DATATYPE_Undefined
Definition: api_core.h:1009
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:373
CSG_Grids::asInt
virtual int asInt(int x, int y, int z, bool bScaled=true) const
Definition: grids.h:391
TSG_Intersection
TSG_Intersection
Definition: geo_tools.h:101
CSG_Grids::Get_ZRange
double Get_ZRange(bool bCells=false) const
Definition: grids.h:207
CSG_Grids::is_NoData
virtual bool is_NoData(sLong i) const
Definition: grids.h:371
CSG_Grids::Mul_Value
virtual void Mul_Value(sLong i, double Value)
Definition: grids.h:419
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:450
CSG_Grids::Get_Offset
double Get_Offset(void) const
Definition: grids.h:271
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:422
CSG_Data_Object::Update
bool Update(bool bForce=false)
Definition: dataobject.cpp:773
CSG_Grids::is_Intersecting
TSG_Intersection is_Intersecting(double xMin, double yMin, double xMax, double yMax) const
Definition: grids.h:299
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:270
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:224
CSG_Grid_System
Definition: grid.h:200
TSG_Grid_Resampling
TSG_Grid_Resampling
Definition: grid.h:156
CSG_Histogram
Definition: mat_tools.h:1001
CSG_Grids::Get_YRange
double Get_YRange(bool bCells=false) const
Definition: grids.h:203
CSG_Grids::Get_Attributes
CSG_Table_Record & Get_Attributes(int i) const
Definition: grids.h:227
CSG_Grids::Get_Grid_Count
int Get_Grid_Count(void) const
Definition: grids.h:249
SSG_Point_3D
Definition: geo_tools.h:264
CSG_Data_Object::is_NoData_Value
bool is_NoData_Value(double Value) const
Definition: dataobject.h:255
GRID_RESAMPLING_Undefined
@ GRID_RESAMPLING_Undefined
Definition: grid.h:168
CSG_Grids::Get_Extent
virtual const CSG_Rect & Get_Extent(void)
Definition: grids.h:183
CSG_Grids::is_InGrid_byPos
bool is_InGrid_byPos(double x, double y, double z, bool bCheckNoData=true) const
Definition: grids.h:307
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:416
grid.h
CSG_Grids::asByte
virtual BYTE asByte(int x, int y, int z, bool bScaled=true) const
Definition: grids.h:385
SSG_Point_3D::x
double x
Definition: geo_tools.h:265
CSG_Grids::Get_NCells
sLong Get_NCells(void) const
Definition: grids.h:188
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:169
CSG_Grids::Get_Z_Attribute
int Get_Z_Attribute(void) const
Definition: grids.h:214
CSG_Grids::is_Scaled
bool is_Scaled(void) const
Definition: grids.h:272
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:406
CSG_File
Definition: api_core.h:1124
SSG_Rect
Definition: geo_tools.h:464
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:202
CSG_Grids::Get_Unit
const SG_Char * Get_Unit(void) const
Definition: grids.h:175
CSG_Grids::Get_Sorted
bool Get_Sorted(sLong Position, int &x, int &y, int &z, bool bDown=true, bool bCheckNoData=true)
Definition: grids.h:470
CSG_Grids::asLong
virtual sLong asLong(sLong i, bool bScaled=true) const
Definition: grids.h:394
CSG_Grids::Get_NX
int Get_NX(void) const
Definition: grids.h:185
CSG_Grids::asShort
virtual short asShort(sLong i, bool bScaled=true) const
Definition: grids.h:390
CSG_Data_Object
Definition: dataobject.h:180
CSG_Grids::Get_System
const CSG_Grid_System & Get_System(void) const
Definition: grids.h:181
CSG_Grids::Get_nLineBytes
int Get_nLineBytes(void) const
Definition: grids.h:172
CSG_Grids::Get_YMin
double Get_YMin(bool bCells=false) const
Definition: grids.h:201
CSG_Grids::asLong
virtual sLong asLong(int x, int y, int z, bool bScaled=true) const
Definition: grids.h:393
CSG_Grids::asByte
virtual BYTE asByte(sLong i, bool bScaled=true) const
Definition: grids.h:386
CSG_Grids::Get_XRange
double Get_XRange(bool bCells=false) const
Definition: grids.h:199
CSG_Grids::Add_Value
virtual void Add_Value(int x, int y, int z, double Value)
Definition: grids.h:415
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:195
CSG_Grids::is_NoData
virtual bool is_NoData(int x, int y, int z) const
Definition: grids.h:370
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:389
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:260
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:308
SAGA_API_DLL_EXPORT
#define SAGA_API_DLL_EXPORT
Definition: api_core.h:94
GRID_RESAMPLING_BSpline
@ GRID_RESAMPLING_BSpline
Definition: grid.h:160
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:198
CSG_Grids::Set_Index
bool Set_Index(bool bOn=true)
Definition: grids.h:438
CSG_Grids::Get_Memory_Size
sLong Get_Memory_Size(void) const
Definition: grids.h:263
CSG_Grids::Get_ZMax
double Get_ZMax(bool bCells=false) const
Definition: grids.h:206
CSG_Grids::Get_XMin
double Get_XMin(bool bCells=false) const
Definition: grids.h:197
CSG_Table
Definition: table.h:283
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:156
CSG_Grids::asFloat
virtual float asFloat(int x, int y, int z, bool bScaled=true) const
Definition: grids.h:395
CSG_Grids::asDouble
virtual double asDouble(sLong i, bool bScaled=true) const
Definition: grids.h:399
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:240
CSG_Array_Pointer
Definition: api_core.h:368
CSG_Grids::asFloat
virtual float asFloat(sLong i, bool bScaled=true) const
Definition: grids.h:396
SSG_Point_3D::y
double y
Definition: geo_tools.h:265
CSG_Grids::asChar
virtual char asChar(int x, int y, int z, bool bScaled=true) const
Definition: grids.h:387
CSG_Grids::Save
virtual bool Save(const wchar_t *File, int Format=0)
Definition: grids.h:157
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:193
CSG_Grid
Definition: grid.h:475
CSG_Grids::Get_Cellsize
double Get_Cellsize(void) const
Definition: grids.h:192
CSG_Grids::is_Modified
virtual bool is_Modified(void) const
Definition: grids.h:326
SSG_Point_3D::z
double z
Definition: geo_tools.h:265
CSG_Grids::is_Intersecting
TSG_Intersection is_Intersecting(const TSG_Rect &Extent) const
Definition: grids.h:298
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:314
CSG_Grids::Set_NoData
virtual void Set_NoData(sLong i)
Definition: grids.h:374
TSG_Data_Type
TSG_Data_Type
Definition: api_core.h:993
CSG_Grids::Set_Value
virtual void Set_Value(int x, int y, int z, double Value, bool bScaled=true)
Definition: grids.h:429
CSG_Grids::Get_ZMin
double Get_ZMin(bool bCells=false) const
Definition: grids.h:205
CSG_Grids::asInt
virtual int asInt(sLong i, bool bScaled=true) const
Definition: grids.h:392
CSG_Grids::Mul_Value
virtual void Mul_Value(int x, int y, int z, double Value)
Definition: grids.h:418
CSG_Grids
Definition: grids.h:119
CSG_Grids::Get_nValueBytes
int Get_nValueBytes(void) const
Definition: grids.h:171
CSG_Simple_Statistics
Definition: mat_tools.h:723
CSG_Grids::Get_Attributes_Ptr
CSG_Table * Get_Attributes_Ptr(void)
Definition: grids.h:225
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_Grids::Get_Grid
const CSG_Grid & Get_Grid(int i) const
Definition: grids.h:259
TSG_Grid_Operation
TSG_Grid_Operation
Definition: grid.h:174
CSG_Grids::Get_Sorted
bool Get_Sorted(sLong Position, sLong &i, bool bDown=true, bool bCheckNoData=true)
Definition: grids.h:465
CSG_Grids::Get_ObjectType
virtual TSG_Data_Object_Type Get_ObjectType(void) const
Definition: grids.h:163
CSG_Grids::Get_NZ
int Get_NZ(void) const
Definition: grids.h:187
GRIDS_FILE_FORMAT_GeoTIFF
@ GRIDS_FILE_FORMAT_GeoTIFF
Definition: grids.h:95