SAGA API v9.10
Loading...
Searching...
No Matches
grid.cpp
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// grid.cpp //
15// //
16// Copyright (C) 2005 by Olaf Conrad //
17// //
18//-------------------------------------------------------//
19// //
20// This file is part of 'SAGA - System for Automated //
21// Geoscientific Analyses'. //
22// //
23// This library is free software; you can redistribute //
24// it and/or modify it under the terms of the GNU Lesser //
25// General Public License as published by the Free //
26// Software Foundation, either version 2.1 of the //
27// License, or (at your option) any later version. //
28// //
29// This library is distributed in the hope that it will //
30// be useful, but WITHOUT ANY WARRANTY; without even the //
31// implied warranty of MERCHANTABILITY or FITNESS FOR A //
32// PARTICULAR PURPOSE. See the GNU Lesser General Public //
33// License for more details. //
34// //
35// You should have received a copy of the GNU Lesser //
36// General Public License along with this program; if //
37// not, see <http://www.gnu.org/licenses/>. //
38// //
39//-------------------------------------------------------//
40// //
41// contact: Olaf Conrad //
42// Institute of Geography //
43// University of Hamburg //
44// Germany //
45// //
46// e-mail: oconrad@saga-gis.org //
47// //
49
50//---------------------------------------------------------
51#include "grid.h"
52#include "data_manager.h"
53
54
56// //
57// //
58// //
60
61//---------------------------------------------------------
62BYTE CSG_Grid::m_Bitmask[8] = { 0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80 };
63
64
66// //
67// //
68// //
70
71//---------------------------------------------------------
73{
74 return( new CSG_Grid );
75}
76
77//---------------------------------------------------------
79{
80 CSG_Grid *pGrid = new CSG_Grid(Grid);
81
82 if( !pGrid->is_Valid() ) { delete(pGrid); return( NULL ); } return( pGrid );
83}
84
85//---------------------------------------------------------
86CSG_Grid * SG_Create_Grid(const char *File, TSG_Data_Type Type, bool bCached, bool bLoadData) { return( SG_Create_Grid(CSG_String(File), Type, bCached, bLoadData) ); }
87CSG_Grid * SG_Create_Grid(const wchar_t *File, TSG_Data_Type Type, bool bCached, bool bLoadData) { return( SG_Create_Grid(CSG_String(File), Type, bCached, bLoadData) ); }
88CSG_Grid * SG_Create_Grid(const CSG_String &File, TSG_Data_Type Type, bool bCached, bool bLoadData)
89{
90 CSG_Grid *pGrid = new CSG_Grid();
91
92 if( pGrid->Create(File, Type, bCached, bLoadData) )
93 {
94 return( pGrid );
95 }
96
97 delete(pGrid); return( NULL );
98}
99
100//---------------------------------------------------------
101CSG_Grid * SG_Create_Grid(CSG_Grid *pGrid, TSG_Data_Type Type, bool bCached)
102{
103 pGrid = new CSG_Grid(pGrid, Type, bCached);
104
105 if( !pGrid->is_Valid() ) { delete(pGrid); return( NULL ); } return( pGrid );
106}
107
108//---------------------------------------------------------
109CSG_Grid * SG_Create_Grid(const CSG_Grid_System &System, TSG_Data_Type Type, bool bCached)
110{
111 CSG_Grid *pGrid = new CSG_Grid(System, Type, bCached);
112
113 if( !pGrid->is_Valid() ) { delete(pGrid); return( NULL ); } return( pGrid );
114}
115
116//---------------------------------------------------------
117CSG_Grid * SG_Create_Grid(TSG_Data_Type Type, int NX, int NY, double Cellsize, double xMin, double yMin, bool bCached)
118{
119 CSG_Grid *pGrid = new CSG_Grid(Type, NX, NY, Cellsize > 0. ? Cellsize : 1., xMin, yMin, bCached);
120
121 if( !pGrid->is_Valid() ) { delete(pGrid); return( NULL ); } return( pGrid );
122}
123
124
126// //
127// //
128// //
130
131//---------------------------------------------------------
135//---------------------------------------------------------
138{
139 _On_Construction();
140}
141
142//---------------------------------------------------------
146//---------------------------------------------------------
149{
150 _On_Construction(); Create(Grid);
151}
152
153//---------------------------------------------------------
157//---------------------------------------------------------
158CSG_Grid::CSG_Grid(const char *File, TSG_Data_Type Type, bool bCached, bool bLoadData) : CSG_Grid(CSG_String(File), Type, bCached, bLoadData) {}
159CSG_Grid::CSG_Grid(const wchar_t *File, TSG_Data_Type Type, bool bCached, bool bLoadData) : CSG_Grid(CSG_String(File), Type, bCached, bLoadData) {}
160CSG_Grid::CSG_Grid(const CSG_String &File, TSG_Data_Type Type, bool bCached, bool bLoadData)
162{
163 _On_Construction(); Create(File, Type, bCached, bLoadData);
164}
165
166//---------------------------------------------------------
170//---------------------------------------------------------
171CSG_Grid::CSG_Grid(CSG_Grid *pGrid, TSG_Data_Type Type, bool bCached)
173{
174 _On_Construction(); Create(pGrid, Type, bCached);
175}
176
177//---------------------------------------------------------
181//---------------------------------------------------------
182CSG_Grid::CSG_Grid(const CSG_Grid_System &System, TSG_Data_Type Type, bool bCached)
184{
185 _On_Construction(); Create(System, Type, bCached);
186}
187
188//---------------------------------------------------------
195//---------------------------------------------------------
196CSG_Grid::CSG_Grid(TSG_Data_Type Type, int NX, int NY, double Cellsize, double xMin, double yMin, bool bCached)
198{
199 _On_Construction(); Create(Type, NX, NY, Cellsize, xMin, yMin, bCached);
200}
201
202
204// //
206
207//---------------------------------------------------------
208void CSG_Grid::_On_Construction(void)
209{
210 m_Type = SG_DATATYPE_Undefined;
211
212 m_Values = NULL;
213
214 m_Cache_Stream = NULL;
215 m_Cache_Offset = 0;
216 m_Cache_bSwap = false;
217 m_Cache_bFlip = false;
218
219 m_zScale = 1.;
220 m_zOffset = 0.;
221
222 m_Index = NULL;
223
224 m_pOwner = NULL;
225
227}
228
229
231// //
233
234//---------------------------------------------------------
235bool CSG_Grid::Create(const CSG_Grid &Grid)
236{
237 if( Create(Grid.Get_System(), Grid.Get_Type()) )
238 {
239 Set_Name (Grid.Get_Name ());
241 Set_Unit (Grid.Get_Unit ());
243 Set_Scaling (Grid.Get_Scaling(), Grid.Get_Offset());
244 Get_MetaData ().Create(Grid.Get_MetaData ());
246
247 #pragma omp parallel for
248 for(int y=0; y<Get_NY(); y++) for(int x=0; x<Get_NX(); x++)
249 {
250 Set_Value(x, y, Grid.asDouble(x, y, false), false);
251 }
252
253 return( true );
254 }
255
256 return( false );
257}
258
259//---------------------------------------------------------
260bool CSG_Grid::Create(CSG_Grid *pGrid, TSG_Data_Type Type, bool bCached)
261{
262 if( pGrid && Create(pGrid->Get_System(), Type == SG_DATATYPE_Undefined ? pGrid->Get_Type() : Type, bCached) )
263 {
265
266 Get_Projection() = pGrid->Get_Projection();
267
268 return( true );
269 }
270
271 return( false );
272}
273
274//---------------------------------------------------------
275bool CSG_Grid::Create(const CSG_Grid_System &_System, TSG_Data_Type Type, bool bCached)
276{
277 CSG_Grid_System System(_System); // just in case _System is identical with this->m_System
278
279 Destroy();
280
281 switch( (m_Type = Type) )
282 {
283 case SG_DATATYPE_Bit : Set_NoData_Value( 0.); break;
284 case SG_DATATYPE_Byte : Set_NoData_Value( 0.); break;
285 case SG_DATATYPE_Char : Set_NoData_Value( -127.); break;
286 case SG_DATATYPE_Word : Set_NoData_Value( 65535.); break;
287 case SG_DATATYPE_Short : Set_NoData_Value( -32767.); break;
288 case SG_DATATYPE_DWord : Set_NoData_Value( 4294967295.); break;
289 case SG_DATATYPE_Int : Set_NoData_Value(-2147483647.); break;
290 case SG_DATATYPE_ULong : Set_NoData_Value( 4294967295.); break;
291 case SG_DATATYPE_Long : Set_NoData_Value(-2147483647.); break;
292 case SG_DATATYPE_Float : Set_NoData_Value( -99999.); break;
293 case SG_DATATYPE_Double: Set_NoData_Value( -99999.); break;
294 case SG_DATATYPE_Color : Set_NoData_Value( 4294967295.); break;
295
296 default : Set_NoData_Value( -99999.);
297 m_Type = SG_DATATYPE_Float;
298 break;
299 }
300
301 if( m_System.Create(System) == false )
302 {
303 m_System.Create(1., System.Get_XMin(), System.Get_YMin(), System.Get_NX(), System.Get_NY());
304 }
305
306 m_Statistics.Invalidate();
307
308 m_nBytes_Value = SG_Data_Type_Get_Size(m_Type);
309 m_nBytes_Line = m_Type == SG_DATATYPE_Bit ? 1 + (size_t)Get_NX() / 8 : (size_t)Get_NX() * m_nBytes_Value;
310
312
313 return( _Memory_Create(bCached) );
314}
315
316//---------------------------------------------------------
317bool CSG_Grid::Create(const char *File, TSG_Data_Type Type, bool bCached, bool bLoadData) { return( Create(CSG_String(File), Type, bCached, bLoadData) ); }
318bool CSG_Grid::Create(const wchar_t *File, TSG_Data_Type Type, bool bCached, bool bLoadData) { return( Create(CSG_String(File), Type, bCached, bLoadData) ); }
319bool CSG_Grid::Create(const CSG_String &File, TSG_Data_Type Type, bool bCached, bool bLoadData)
320{
321 Destroy();
322
323 SG_UI_Msg_Add(CSG_String::Format("%s: %s...", _TL("Loading grid"), File.c_str()), true);
324
325 m_Type = Type;
326
327 if( _Load_PGSQL (File, bCached, bLoadData)
328 || _Load_Native (File, bCached, bLoadData)
329 || _Load_Compressed(File, bCached, bLoadData)
330 || _Load_Surfer (File, bCached, bLoadData)
331 || _Load_External (File, bCached, bLoadData) )
332 {
334
335 Set_Modified(false);
337
340
341 return( true );
342 }
343
344 Destroy();
345
347 SG_UI_Msg_Add(_TL("failed"), false, SG_UI_MSG_STYLE_FAILURE);
348
349 return( false );
350}
351
352//---------------------------------------------------------
353bool CSG_Grid::Create(TSG_Data_Type Type, int NX, int NY, double Cellsize, double xMin, double yMin, bool bCached)
354{
355 Destroy();
356
357 return( Create(CSG_Grid_System(Cellsize, xMin, yMin, NX, NY), Type, bCached) );
358}
359
360
362// //
363// Destruction //
364// //
366
367//---------------------------------------------------------
372{
373 Destroy();
374}
375
380{
381 _Memory_Destroy();
382
383 m_Type = SG_DATATYPE_Undefined;
384
385 m_zScale = 1.;
386 m_zOffset = 0.;
387
388 m_Unit .Clear ();
389 m_System.Destroy();
390
391 return( CSG_Data_Object::Destroy() );
392}
393
394
396// //
398
399//---------------------------------------------------------
401{
402 m_Unit = Unit;
403}
404
405//---------------------------------------------------------
406void CSG_Grid::Set_Scaling(double Scale, double Offset)
407{
408 if( (Scale != m_zScale && Scale != 0.) || Offset != m_zOffset )
409 {
410 if( Scale != 0. )
411 {
412 m_zScale = Scale;
413 }
414
415 m_zOffset = Offset;
416
418 }
419}
420
421//---------------------------------------------------------
422double CSG_Grid::Get_Scaling(void) const
423{
424 return( m_zScale );
425}
426
427//---------------------------------------------------------
428double CSG_Grid::Get_Offset(void) const
429{
430 return( m_zOffset );
431}
432
433
435// //
436// Checks //
437// //
439
440//---------------------------------------------------------
441bool CSG_Grid::is_Valid(void) const
442{
443 if( m_System.is_Valid() && m_Type != SG_DATATYPE_Undefined )
444 {
445 return( m_Values != NULL || is_Cached() );
446 }
447
448 return( false );
449}
450
451//---------------------------------------------------------
453{
454 return( Get_Extent().Intersects(Extent) );
455}
456
458{
459 return( Get_Extent().Intersects(Extent) );
460}
461
462TSG_Intersection CSG_Grid::is_Intersecting(double xMin, double yMin, double xMax, double yMax) const
463{
464 return( is_Intersecting(CSG_Rect(xMin, yMin, xMax, yMax)) );
465}
466
467//---------------------------------------------------------
469{
470 return( pGrid && is_Compatible(pGrid->Get_System()) );
471}
472
474{
475 return( m_System == System );
476}
477
478bool CSG_Grid::is_Compatible(int NX, int NY, double Cellsize, double xMin, double yMin) const
479{
480 return( is_Compatible(CSG_Grid_System(Cellsize, xMin, yMin, NX, NY)) );
481}
482
483
485// //
486// value access by row //
487// //
489
490//---------------------------------------------------------
492{
493 CSG_Vector Values;
494
495 if( y >= 0 && y < Get_NY() )
496 {
497 Values.Create(Get_NX());
498
499 for(int x=0; x<Get_NX(); x++)
500 {
501 Values[x] = asDouble(x, y);
502 }
503 }
504
505 return( Values );
506}
507
508//---------------------------------------------------------
509bool CSG_Grid::Set_Row(int y, const CSG_Vector &Values)
510{
511 if( y >= 0 && y < Get_NY() && Values.Get_N() == Get_NX() )
512 {
513 for(int x=0; x<Get_NX(); x++)
514 {
515 Set_Value(x, y, Values[x]);
516 }
517
518 return( true );
519 }
520
521 return( false );
522}
523
524
526// //
527// Value access by Position (-> Interpolation) //
528// //
530
531//---------------------------------------------------------
532double CSG_Grid::Get_Value(const TSG_Point &p, CSG_Grid_Resampling Resampling, bool bByteWise) const
533{
534 double Value;
535
536 return( Get_Value(p.x, p.y, Value, Resampling, false, bByteWise) ? Value : Get_NoData_Value() );
537}
538
539double CSG_Grid::Get_Value(double x, double y, CSG_Grid_Resampling Resampling, bool bByteWise) const
540{
541 double Value;
542
543 return( Get_Value(x, y, Value, Resampling, false, bByteWise) ? Value : Get_NoData_Value() );
544}
545
546bool CSG_Grid::Get_Value(const TSG_Point &p, double &Value, CSG_Grid_Resampling Resampling, bool bNoData, bool bByteWise) const
547{
548 return( Get_Value(p.x, p.y, Value, Resampling, bNoData, bByteWise) );
549}
550
551//---------------------------------------------------------
552bool CSG_Grid::Get_Value(double x, double y, double &Value, CSG_Grid_Resampling Resampling, bool bNoData, bool bByteWise) const
553{
554 if( m_System.Get_Extent(true).Contains(x, y) )
555 {
556 int ix = (int)floor(x = (x - Get_XMin()) / Get_Cellsize()); double dx = x - ix;
557 int iy = (int)floor(y = (y - Get_YMin()) / Get_Cellsize()); double dy = y - iy;
558
559 if( bNoData || is_InGrid(ix + (int)(0.5 + dx), iy + (int)(0.5 + dy)) )
560 {
561 switch( Resampling )
562 {
563 case CSG_Grid_Resampling::NearestNeighbour : return( _Get_ValAtPos_NearestNeighbour(Value, ix, iy, dx, dy ) );
564 case CSG_Grid_Resampling::Bilinear : return( _Get_ValAtPos_BiLinear (Value, ix, iy, dx, dy, bByteWise) );
565 case CSG_Grid_Resampling::Bicubic_1 : return( _Get_ValAtPos_BiCubic_1 (Value, ix, iy, dx, dy, bByteWise) );
566 case CSG_Grid_Resampling::Bicubic_2: default: return( _Get_ValAtPos_BiCubic_2 (Value, ix, iy, dx, dy, bByteWise) );
567 }
568 }
569 }
570
571 Value = Get_NoData_Value();
572
573 return( false );
574}
575
576
578// //
580
581//---------------------------------------------------------
582inline bool CSG_Grid::_Get_ValAtPos_NearestNeighbour(double &Value, int x, int y, double dx, double dy) const
583{
584 if( is_InGrid(x = x + (int)(0.5 + dx), y = y + (int)(0.5 + dy)) )
585 {
586 Value = asDouble(x, y);
587
588 return( true );
589 }
590
591 return( false );
592}
593
594
596// //
598
599//---------------------------------------------------------
600inline bool CSG_Grid::_Get_ValAtPos_BiLinear(double &Value, int x, int y, double dx, double dy, bool bByteWise) const
601{
602 if( !bByteWise )
603 {
604 double z = 0., n = 0.;
605
606 #define BILINEAR_ADD(ix, iy, d) if( is_InGrid(ix, iy) ) { n += d; z += d * asDouble(ix, iy); }
607
608 BILINEAR_ADD(x , y , (1. - dx) * (1. - dy));
609 BILINEAR_ADD(x + 1, y , ( dx) * (1. - dy));
610 BILINEAR_ADD(x , y + 1, (1. - dx) * ( dy));
611 BILINEAR_ADD(x + 1, y + 1, ( dx) * ( dy));
612
613 #undef BILINEAR_ADD
614
615 if( n > 0. )
616 {
617 Value = z / n;
618
619 return( true );
620 }
621 }
622
623 //-----------------------------------------------------
624 else
625 {
626 double n = 0.; CSG_Vector z(4);
627
628 #define BILINEAR_ADD(ix, iy, d) if( is_InGrid(ix, iy) ) { n += d; int v = asInt(ix, iy);\
629 z[0] += d * SG_GET_BYTE_0(v);\
630 z[1] += d * SG_GET_BYTE_1(v);\
631 z[2] += d * SG_GET_BYTE_2(v);\
632 z[3] += d * SG_GET_BYTE_3(v);\
633 }
634
635 BILINEAR_ADD(x , y , (1. - dx) * (1. - dy));
636 BILINEAR_ADD(x + 1, y , ( dx) * (1. - dy));
637 BILINEAR_ADD(x , y + 1, (1. - dx) * ( dy));
638 BILINEAR_ADD(x + 1, y + 1, ( dx) * ( dy));
639
640 #undef BILINEAR_ADD
641
642 if( n > 0. )
643 {
644 z *= 1. / n;
645
646 BYTE Bytes[4] = { (BYTE)z[0], (BYTE)z[1], (BYTE)z[2], (BYTE)z[3] };
647
648 Value = *(int *)Bytes;
649
650 return( true );
651 }
652 }
653
654 return( false );
655}
656
657
659// //
661
662//---------------------------------------------------------
663inline double CSG_Grid::_Get_ValAtPos_BiCubic_1(double dx, double dy, double v_xy[4][4]) const
664{
665 #define BiCubicSpline(d, v) (v[1] + 0.5 * d * (v[2] - v[0] + d * (2 * v[0] - 5 * v[1] + 4 * v[2] - v[3] + d * (3 * (v[1] - v[2]) + v[3] - v[0]))))
666
667 double v_x[4];
668
669 for(int ix=0; ix<4; ix++)
670 {
671 v_x[ix] = BiCubicSpline(dy, v_xy[ix]);
672 }
673
674 return( BiCubicSpline(dx, v_x) );
675}
676
677//---------------------------------------------------------
678inline bool CSG_Grid::_Get_ValAtPos_BiCubic_1(double &Value, int x, int y, double dx, double dy, bool bByteWise) const
679{
680 if( !bByteWise )
681 {
682 double v_xy[4][4];
683
684 if( _Get_ValAtPos_Fill4x4Submatrix(x, y, v_xy) )
685 {
686 Value = _Get_ValAtPos_BiCubic_1(dx, dy, v_xy);
687
688 return( true );
689 }
690 }
691 else
692 {
693 double v_xy[4][4][4];
694
695 if( _Get_ValAtPos_Fill4x4Submatrix(x, y, v_xy) )
696 {
697 BYTE Bytes[4];
698
699 #define SET_BYTE(b, z) { double d = z; b = (BYTE)(d < 0. ? 0. : d < 255. ? d : 255.); }
700
701 SET_BYTE(Bytes[0], _Get_ValAtPos_BiCubic_1(dx, dy, v_xy[0]));
702 SET_BYTE(Bytes[1], _Get_ValAtPos_BiCubic_1(dx, dy, v_xy[1]));
703 SET_BYTE(Bytes[2], _Get_ValAtPos_BiCubic_1(dx, dy, v_xy[2]));
704 SET_BYTE(Bytes[3], _Get_ValAtPos_BiCubic_1(dx, dy, v_xy[3]));
705
706 Value = *(int *)Bytes;
707
708 return( true );
709 }
710 }
711
712 return( false );
713}
714
715
717// //
719
720//---------------------------------------------------------
721inline double CSG_Grid::_Get_ValAtPos_BiCubic_2(double dx, double dy, double v_xy[4][4]) const
722{
723 double Rx[4], Ry[4];
724
725 for(int i=0; i<4; i++)
726 {
727 double d, s;
728
729 s = 0.;
730 if( (d = i - dx + 1.) > 0. ) s += d*d*d;
731 if( (d = i - dx + 0.) > 0. ) s += -4. * d*d*d;
732 if( (d = i - dx - 1.) > 0. ) s += 6. * d*d*d;
733 if( (d = i - dx - 2.) > 0. ) s += -4. * d*d*d;
734 // if( (d = i - dx - 3.) > 0. ) s += d*d*d;
735 Rx[i] = s / 6.;
736
737 s = 0.;
738 if( (d = i - dy + 1.) > 0. ) s += d*d*d;
739 if( (d = i - dy + 0.) > 0. ) s += -4. * d*d*d;
740 if( (d = i - dy - 1.) > 0. ) s += 6. * d*d*d;
741 if( (d = i - dy - 2.) > 0. ) s += -4. * d*d*d;
742 // if( (d = i - dy - 3.) > 0. ) s += d*d*d;
743 Ry[i] = s / 6.;
744 }
745
746 double z = 0.;
747
748 for(int iy=0; iy<4; iy++)
749 {
750 for(int ix=0; ix<4; ix++)
751 {
752 z += v_xy[ix][iy] * Rx[ix] * Ry[iy];
753 }
754 }
755
756 return( z );
757}
758
759//---------------------------------------------------------
760inline bool CSG_Grid::_Get_ValAtPos_BiCubic_2(double &Value, int x, int y, double dx, double dy, bool bByteWise) const
761{
762 if( !bByteWise )
763 {
764 double v_xy[4][4];
765
766 if( _Get_ValAtPos_Fill4x4Submatrix(x, y, v_xy) )
767 {
768 Value = _Get_ValAtPos_BiCubic_2(dx, dy, v_xy);
769
770 return( true );
771 }
772 }
773 else
774 {
775 double v_xy[4][4][4];
776
777 if( _Get_ValAtPos_Fill4x4Submatrix(x, y, v_xy) )
778 {
779 BYTE Bytes[4] = {
780 (BYTE)_Get_ValAtPos_BiCubic_2(dx, dy, v_xy[0]),
781 (BYTE)_Get_ValAtPos_BiCubic_2(dx, dy, v_xy[1]),
782 (BYTE)_Get_ValAtPos_BiCubic_2(dx, dy, v_xy[2]),
783 (BYTE)_Get_ValAtPos_BiCubic_2(dx, dy, v_xy[3])
784 };
785
786 Value = *(int *)Bytes;
787
788 return( true );
789 }
790 }
791
792 return( false );
793}
794
795
797// //
799
800//---------------------------------------------------------
801inline bool CSG_Grid::_Get_ValAtPos_Fill4x4Submatrix(int x, int y, double v_xy[4][4]) const
802{
803 int ix, iy, jx, jy, nNoData = 0;
804
805 //-----------------------------------------------------
806 for(iy=0, jy=y-1; iy<4; iy++, jy++)
807 {
808 for(ix=0, jx=x-1; ix<4; ix++, jx++)
809 {
810 if( is_InGrid(jx, jy) )
811 {
812 v_xy[ix][iy] = asDouble(jx, jy);
813 }
814 else
815 {
816 v_xy[ix][iy] = Get_NoData_Value();
817
818 nNoData++;
819 }
820 }
821 }
822
823 //-----------------------------------------------------
824 for(int i=0; nNoData>0 && nNoData<16 && i<16; i++) // guess missing values as average of surrounding data values
825 {
826 double t_xy[4][4];
827
828 for(iy=0; iy<4; iy++) for(ix=0; ix<4; ix++)
829 {
830 t_xy[ix][iy] = v_xy[ix][iy];
831 }
832
833 for(iy=0; iy<4; iy++) for(ix=0; ix<4; ix++)
834 {
835 if( is_NoData_Value(t_xy[ix][iy]) )
836 {
837 int n = 0;
838 double s = 0.;
839
840 for(jy=iy-1; jy<=iy+1; jy++) for(jx=ix-1; jx<=ix+1; jx++)
841 {
842 if( is_InGrid(jx + x - 1, jy + y - 1) )
843 {
844 s += asDouble(jx + x - 1, jy + y - 1);
845 n ++;
846 }
847 else if( jy >= 0 && jy < 4 && jx >= 0 && jx < 4 && !is_NoData_Value(t_xy[jx][jy]) )
848 {
849 s += t_xy[jx][jy];
850 n ++;
851 }
852 }
853
854 if( n > 0 )
855 {
856 v_xy[ix][iy] = s / n;
857
858 nNoData--;
859 }
860 }
861 }
862 }
863
864 //-----------------------------------------------------
865 return( nNoData == 0 );
866}
867
868//---------------------------------------------------------
869inline bool CSG_Grid::_Get_ValAtPos_Fill4x4Submatrix(int x, int y, double v_xy[4][4][4]) const
870{
871 int ix, iy, jx, jy, nNoData = 0;
872
873 //-----------------------------------------------------
874 for(iy=0, jy=y-1; iy<4; iy++, jy++)
875 {
876 for(ix=0, jx=x-1; ix<4; ix++, jx++)
877 {
878 if( is_InGrid(jx, jy) )
879 {
880 int z = asInt(jx, jy);
881
882 v_xy[0][ix][iy] = SG_GET_BYTE_0(z);
883 v_xy[1][ix][iy] = SG_GET_BYTE_1(z);
884 v_xy[2][ix][iy] = SG_GET_BYTE_2(z);
885 v_xy[3][ix][iy] = SG_GET_BYTE_3(z);
886 }
887 else
888 {
889 v_xy[0][ix][iy] = -1;
890
891 nNoData++;
892 }
893 }
894 }
895
896 //-----------------------------------------------------
897 for(int i=0; nNoData>0 && nNoData<16 && i<16; i++) // guess missing values as average of surrounding data values
898 {
899 double t_xy[4][4][4];
900
901 for(iy=0; iy<4; iy++) for(ix=0; ix<4; ix++)
902 {
903 t_xy[0][ix][iy] = v_xy[0][ix][iy];
904 t_xy[1][ix][iy] = v_xy[1][ix][iy];
905 t_xy[2][ix][iy] = v_xy[2][ix][iy];
906 t_xy[3][ix][iy] = v_xy[3][ix][iy];
907 }
908
909 for(iy=0; iy<4; iy++) for(ix=0; ix<4; ix++)
910 {
911 if( t_xy[0][ix][iy] < 0 )
912 {
913 int n = 0;
914 double s[4]; s[0] = s[1] = s[2] = s[3] = 0.;
915
916 for(jy=iy-1; jy<=iy+1; jy++) for(jx=ix-1; jx<=ix+1; jx++)
917 {
918 if( is_InGrid(jx + x - 1, jy + y - 1) )
919 {
920 int z = asInt(jx + x - 1, jy + y - 1);
921
922 s[0] += SG_GET_BYTE_0(z);
923 s[1] += SG_GET_BYTE_1(z);
924 s[2] += SG_GET_BYTE_2(z);
925 s[3] += SG_GET_BYTE_3(z);
926 n ++;
927 }
928 else if( jy >= 0 && jy < 4 && jx >= 0 && jx < 4 && !is_NoData_Value(t_xy[0][jx][jy]) )
929 {
930 s[0] += t_xy[0][jx][jy];
931 s[1] += t_xy[1][jx][jy];
932 s[2] += t_xy[2][jx][jy];
933 s[3] += t_xy[3][jx][jy];
934 n ++;
935 }
936 }
937
938 if( n > 0 )
939 {
940 v_xy[0][ix][iy] = s[0] / n;
941 v_xy[1][ix][iy] = s[1] / n;
942 v_xy[2][ix][iy] = s[2] / n;
943 v_xy[3][ix][iy] = s[3] / n;
944
945 nNoData--;
946 }
947 }
948 }
949 }
950
951 //-----------------------------------------------------
952 return( nNoData == 0 );
953}
954
955
957// //
958// Statistics //
959// //
961
962//---------------------------------------------------------
964{
965 if( !is_Valid() )
966 {
967 return( false );
968 }
969
970 SG_FREE_SAFE(m_Index);
971
972 m_Statistics.Invalidate();
973 m_Histogram.Destroy();
974
975 double Offset = Get_Offset(), Scaling = is_Scaled() ? Get_Scaling() : 0.;
976
977 if( Get_Max_Samples() > 0 && Get_Max_Samples() < Get_NCells() )
978 {
979 double d = (double)Get_NCells() / (double)Get_Max_Samples();
980
981 for(double i=0; i<(double)Get_NCells(); i+=d)
982 {
983 double Value = asDouble((sLong)i, false);
984
985 if( !is_NoData_Value(Value) )
986 {
987 m_Statistics += Scaling ? Offset + Scaling * Value : Value;
988 }
989 }
990
991 m_Statistics.Set_Count(m_Statistics.Get_Count() >= Get_Max_Samples() ? Get_NCells() // any no-data cells ?
992 : (sLong)(Get_NCells() * (double)m_Statistics.Get_Count() / (double)Get_Max_Samples())
993 );
994 }
995 else
996 {
997 for(int y=0; y<Get_NY() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
998 {
999 for(int x=0; x<Get_NX(); x++)
1000 {
1001 double Value = asDouble(x, y, false);
1002
1003 if( !is_NoData_Value(Value) )
1004 {
1005 m_Statistics += Scaling ? Offset + Scaling * Value : Value;
1006 }
1007 }
1008 }
1009
1011 }
1012
1013 return( true );
1014}
1015
1016//---------------------------------------------------------
1018{
1019 Update(); return( m_Statistics.Get_Mean() );
1020}
1021
1023{
1024 Update(); return( m_Statistics.Get_Minimum() );
1025}
1026
1028{
1029 Update(); return( m_Statistics.Get_Maximum() );
1030}
1031
1033{
1034 Update(); return( m_Statistics.Get_Range() );
1035}
1036
1038{
1039 Update(); return( m_Statistics.Get_StdDev() );
1040}
1041
1043{
1044 Update(); return( m_Statistics.Get_Variance() );
1045}
1046
1047//---------------------------------------------------------
1049{
1050 Update(); return( m_Statistics.Get_Count() );
1051}
1052
1054{
1055 Update(); return( Get_NCells() - m_Statistics.Get_Count() );
1056}
1057
1058//---------------------------------------------------------
1059double CSG_Grid::Get_Quantile(double Quantile, bool bFromHistogram)
1060{
1061 if( Quantile <= 0. ) { return( Get_Min() ); }
1062 if( Quantile >= 1. ) { return( Get_Max() ); }
1063
1064 if( bFromHistogram )
1065 {
1066 return( Get_Histogram().Get_Quantile(Quantile) );
1067 }
1068 else
1069 {
1070 sLong n = (sLong)(Quantile * (Get_Data_Count() - 1));
1071
1072 if( Get_Sorted(n, n, false) )
1073 {
1074 return( asDouble(n) );
1075 }
1076 }
1077
1078 return( Get_NoData_Value() );
1079}
1080
1081//---------------------------------------------------------
1082double CSG_Grid::Get_Percentile(double Percentile, bool bFromHistogram)
1083{
1084 return( Get_Quantile(0.01 * Percentile, bFromHistogram) );
1085}
1086
1087
1089// //
1091
1092//---------------------------------------------------------
1100{
1101 Update(); return( m_Statistics );
1102}
1103
1104//---------------------------------------------------------
1110//---------------------------------------------------------
1111bool CSG_Grid::Get_Statistics(const CSG_Rect &rWorld, CSG_Simple_Statistics &Statistics, bool bHoldValues) const
1112{
1113 int xMin = Get_System().Get_xWorld_to_Grid(rWorld.Get_XMin()); if( xMin < 0 ) xMin = 0;
1114 int yMin = Get_System().Get_yWorld_to_Grid(rWorld.Get_YMin()); if( yMin < 0 ) yMin = 0;
1115 int xMax = Get_System().Get_xWorld_to_Grid(rWorld.Get_XMax()); if( xMax >= Get_NX() ) xMax = Get_NX() - 1;
1116 int yMax = Get_System().Get_yWorld_to_Grid(rWorld.Get_YMax()); if( yMax >= Get_NY() ) yMax = Get_NY() - 1;
1117
1118 if( xMin > xMax || yMin > yMax )
1119 {
1120 return( false ); // no overlap
1121 }
1122
1123 Statistics.Create(bHoldValues);
1124
1125 int nx = 1 + (xMax - xMin);
1126 int ny = 1 + (yMax - yMin);
1127 sLong nCells = nx * ny;
1128
1129 double Offset = Get_Offset(), Scaling = is_Scaled() ? Get_Scaling() : 0.;
1130
1131 if( Get_Max_Samples() > 0 && Get_Max_Samples() < nCells )
1132 {
1133 double d = (double)nCells / (double)Get_Max_Samples();
1134
1135 for(double i=0; i<(double)nCells; i+=d)
1136 {
1137 int y = yMin + (int)i / nx;
1138 int x = xMin + (int)i % nx;
1139
1140 double Value = asDouble(x, y, false);
1141
1142 if( !is_NoData_Value(Value) )
1143 {
1144 Statistics += Scaling ? Offset + Scaling * Value : Value;
1145 }
1146 }
1147 }
1148 else
1149 {
1150 for(int y=yMin; y<=yMax; y++)
1151 {
1152 for(int x=xMin; x<=xMax; x++)
1153 {
1154 double Value = asDouble(x, y, false);
1155
1156 if( !is_NoData_Value(Value) )
1157 {
1158 Statistics += Scaling ? Offset + Scaling * Value : Value;
1159 }
1160 }
1161 }
1162 }
1163
1164 return( Statistics.Get_Count() > 0 );
1165}
1166
1167//---------------------------------------------------------
1168#define SG_GRID_HISTOGRAM_CLASSES_DEFAULT 256
1169
1170//---------------------------------------------------------
1176{
1177 Update();
1178
1179 if( nClasses > 1 && nClasses != m_Histogram.Get_Class_Count() )
1180 {
1181 m_Histogram.Destroy();
1182 }
1183
1184 if( m_Histogram.Get_Statistics().Get_Count() < 1 )
1185 {
1186 m_Histogram.Create(nClasses > 1 ? nClasses : SG_GRID_HISTOGRAM_CLASSES_DEFAULT, this, 0., 0., (size_t)Get_Max_Samples());
1187 }
1188
1189 return( m_Histogram );
1190}
1191
1192//---------------------------------------------------------
1193bool CSG_Grid::Get_Histogram(const CSG_Rect &rWorld, CSG_Histogram &Histogram, size_t nClasses) const
1194{
1195 CSG_Simple_Statistics Statistics;
1196
1197 if( !Get_Statistics(rWorld, Statistics) )
1198 {
1199 return( false );
1200 }
1201
1202 int xMin = Get_System().Get_xWorld_to_Grid(rWorld.Get_XMin()); if( xMin < 0 ) { xMin = 0; }
1203 int yMin = Get_System().Get_yWorld_to_Grid(rWorld.Get_YMin()); if( yMin < 0 ) { yMin = 0; }
1204 int xMax = Get_System().Get_xWorld_to_Grid(rWorld.Get_XMax()); if( xMax >= Get_NX() ) { xMax = Get_NX() - 1; }
1205 int yMax = Get_System().Get_yWorld_to_Grid(rWorld.Get_YMax()); if( yMax >= Get_NY() ) { yMax = Get_NY() - 1; }
1206
1207 if( xMin > xMax || yMin > yMax )
1208 {
1209 return( false ); // no overlap
1210 }
1211
1212 Histogram.Create(nClasses > 1 ? nClasses : SG_GRID_HISTOGRAM_CLASSES_DEFAULT, Statistics.Get_Minimum(), Statistics.Get_Maximum());
1213
1214 int nx = 1 + (xMax - xMin);
1215 int ny = 1 + (yMax - yMin);
1216 sLong nCells = (sLong)nx * (sLong)ny;
1217
1218 double Offset = Get_Offset(), Scaling = is_Scaled() ? Get_Scaling() : 0.;
1219
1220 if( Get_Max_Samples() > 0 && Get_Max_Samples() < nCells )
1221 {
1222 double d = (double)nCells / (double)Get_Max_Samples();
1223
1224 for(double i=0; i<(double)nCells; i+=d)
1225 {
1226 int y = yMin + (int)i / nx;
1227 int x = xMin + (int)i % nx;
1228
1229 double Value = asDouble(x, y, false);
1230
1231 if( !is_NoData_Value(Value) )
1232 {
1233 Histogram += Scaling ? Offset + Scaling * Value : Value;
1234 }
1235 }
1236 }
1237 else
1238 {
1239 for(int y=yMin; y<=yMax; y++) for(int x=xMin; x<=xMax; x++)
1240 {
1241 double Value = asDouble(x, y, false);
1242
1243 if( !is_NoData_Value(Value) )
1244 {
1245 Histogram += Scaling ? Offset + Scaling * Value : Value;
1246 }
1247 }
1248 }
1249
1250 return( Histogram.Update() );
1251}
1252
1253
1255// //
1256// Index //
1257// //
1259
1260//---------------------------------------------------------
1261bool CSG_Grid::_Set_Index(void)
1262{
1263 if( m_Index == NULL && (m_Index = (sLong *)SG_Malloc((size_t)Get_NCells() * sizeof(sLong))) == NULL )
1264 {
1265 SG_UI_Msg_Add_Error(_TL("could not create index: insufficient memory"));
1266
1267 return( false );
1268 }
1269
1270 //-----------------------------------------------------
1271 const sLong M = 7;
1272
1273 sLong i, j, k, l, ir, n, *istack, jstack, nstack, indxt, itemp, nData;
1274 double a;
1275
1276 //-----------------------------------------------------
1277 SG_UI_Process_Set_Text(CSG_String::Format("%s: %s", _TL("Create index"), Get_Name()));
1278
1279 for(i=0, j=0, nData=Get_NCells(); i<Get_NCells(); i++)
1280 {
1281 if( is_NoData(i) )
1282 {
1283 m_Index[--nData] = i;
1284 }
1285 else // if( !is_NoData(i) )
1286 {
1287 m_Index[j++] = i;
1288 }
1289 }
1290
1291 if( nData <= 0 )
1292 {
1293 // SG_FREE_SAFE(m_Index);
1294
1295 return( false ); // nothing to do
1296 }
1297
1298 //-----------------------------------------------------
1299 l = 0;
1300 n = 0;
1301 ir = nData - 1;
1302
1303 nstack = 64;
1304 istack = (sLong *)SG_Malloc((size_t)nstack * sizeof(sLong));
1305 jstack = 0;
1306
1307 for(;;)
1308 {
1309 if( ir - l < M )
1310 {
1311 if( !SG_UI_Process_Set_Progress((double)(n += M - 1), (double)nData) )
1312 {
1313 SG_FREE_SAFE(istack);
1314 SG_FREE_SAFE(m_Index);
1315
1316 SG_UI_Msg_Add_Error(_TL("index creation stopped by user"));
1318
1319 return( false );
1320 }
1321
1322 for(j=l+1; j<=ir; j++)
1323 {
1324 indxt = m_Index[j];
1325 a = asDouble(indxt);
1326
1327 for(i=j-1; i>=0; i--)
1328 {
1329 if( asDouble(m_Index[i]) <= a )
1330 {
1331 break;
1332 }
1333
1334 m_Index[i + 1] = m_Index[i];
1335 }
1336
1337 m_Index[i + 1] = indxt;
1338 }
1339
1340 if( jstack == 0 )
1341 {
1342 break;
1343 }
1344
1345 ir = istack[jstack--];
1346 l = istack[jstack--];
1347 }
1348
1349 //-------------------------------------------------
1350 else
1351 {
1352 #define SORT_SWAP(a,b) {itemp=(a);(a)=(b);(b)=itemp;}
1353
1354 k = (l + ir) >> 1;
1355
1356 SORT_SWAP(m_Index[k], m_Index[l + 1]);
1357
1358 if( asDouble( m_Index[l + 1]) > asDouble(m_Index[ir]) )
1359 SORT_SWAP(m_Index[l + 1], m_Index[ir]);
1360
1361 if( asDouble( m_Index[l ]) > asDouble(m_Index[ir]) )
1362 SORT_SWAP(m_Index[l ], m_Index[ir]);
1363
1364 if( asDouble( m_Index[l + 1]) > asDouble(m_Index[l ]) )
1365 SORT_SWAP(m_Index[l + 1], m_Index[l ]);
1366
1367 i = l + 1;
1368 j = ir;
1369 indxt = m_Index[l];
1370 a = asDouble(indxt);
1371
1372 for(;;)
1373 {
1374 do i++; while(asDouble(m_Index[i]) < a);
1375 do j--; while(asDouble(m_Index[j]) > a);
1376
1377 if( j < i )
1378 {
1379 break;
1380 }
1381
1382 SORT_SWAP(m_Index[i], m_Index[j]);
1383 }
1384
1385 #undef SORT_SWAP
1386
1387 m_Index[l] = m_Index[j];
1388 m_Index[j] = indxt;
1389 jstack += 2;
1390
1391 if( jstack >= nstack )
1392 {
1393 nstack += 64;
1394 istack = (sLong *)SG_Realloc(istack, (size_t)nstack * sizeof(int));
1395 }
1396
1397 if( ir - i + 1 >= j - l )
1398 {
1399 istack[jstack] = ir;
1400 istack[jstack - 1] = i;
1401 ir = j - 1;
1402 }
1403 else
1404 {
1405 istack[jstack] = j - 1;
1406 istack[jstack - 1] = l;
1407 l = i;
1408 }
1409 }
1410 }
1411
1412 //-----------------------------------------------------
1413 SG_Free(istack);
1414
1416
1417 return( true );
1418}
1419
1420
1422// //
1423// //
1424// //
1426
1427//---------------------------------------------------------
void SG_UI_Msg_Add_Error(const char *Message)
void SG_UI_Msg_Add(const char *Message, bool bNewLine, TSG_UI_MSG_STYLE Style)
void SG_UI_Process_Set_Text(const CSG_String &Text)
bool SG_UI_Process_Set_Ready(void)
bool SG_UI_Process_Set_Progress(int Position, int Range)
@ SG_UI_MSG_STYLE_FAILURE
Definition api_core.h:1585
@ SG_UI_MSG_STYLE_SUCCESS
Definition api_core.h:1584
#define SG_GET_BYTE_1(vLong)
Definition api_core.h:195
SAGA_API_DLL_EXPORT void * SG_Malloc(size_t size)
signed long long sLong
Definition api_core.h:158
SAGA_API_DLL_EXPORT void SG_Free(void *memblock)
SAGA_API_DLL_EXPORT void * SG_Realloc(void *memblock, size_t size)
#define SG_GET_BYTE_3(vLong)
Definition api_core.h:197
#define SG_FREE_SAFE(PTR)
Definition api_core.h:205
#define SG_GET_BYTE_2(vLong)
Definition api_core.h:196
TSG_Data_Type
Definition api_core.h:997
@ SG_DATATYPE_Long
Definition api_core.h:1006
@ SG_DATATYPE_Byte
Definition api_core.h:999
@ SG_DATATYPE_Bit
Definition api_core.h:998
@ SG_DATATYPE_Short
Definition api_core.h:1002
@ SG_DATATYPE_Word
Definition api_core.h:1001
@ SG_DATATYPE_ULong
Definition api_core.h:1005
@ SG_DATATYPE_Float
Definition api_core.h:1007
@ SG_DATATYPE_Undefined
Definition api_core.h:1013
@ SG_DATATYPE_Double
Definition api_core.h:1008
@ SG_DATATYPE_Color
Definition api_core.h:1011
@ SG_DATATYPE_Int
Definition api_core.h:1004
@ SG_DATATYPE_Char
Definition api_core.h:1000
@ SG_DATATYPE_DWord
Definition api_core.h:1003
#define _TL(s)
Definition api_core.h:1568
size_t SG_Data_Type_Get_Size(TSG_Data_Type Type)
Definition api_core.h:1064
#define SG_GET_BYTE_0(vLong)
Definition api_core.h:194
const SG_Char * Get_Name(void) const
CSG_Data_Object * m_pOwner
Definition dataobject.h:271
void Set_Name(const CSG_String &Name)
bool is_NoData_Value(double Value) const
Definition dataobject.h:255
void Set_Update_Flag(bool bOn=true)
Definition dataobject.h:285
virtual bool Set_Max_Samples(sLong Max_Samples)
double Get_NoData_Value(bool bUpper=false) const
Definition dataobject.h:253
CSG_MetaData & Get_MetaData(void) const
Definition dataobject.h:234
virtual bool Set_NoData_Value_Range(double Lower, double Upper)
bool Update(bool bForce=false)
virtual bool Destroy(void)
void Set_Description(const CSG_String &Description)
virtual bool Set_NoData_Value(double Value)
const SG_Char * Get_Description(void) const
sLong Get_Max_Samples(void) const
Definition dataobject.h:263
CSG_Projection & Get_Projection(void)
double Get_XMin(bool bCells=false) const
Definition grid.h:264
double Get_YMin(bool bCells=false) const
Definition grid.h:268
int Get_xWorld_to_Grid(double xWorld) const
Definition grid.h:318
int Get_yWorld_to_Grid(double yWorld) const
Definition grid.h:319
int Get_NX(void) const
Definition grid.h:258
int Get_NY(void) const
Definition grid.h:259
int Get_NY(void) const
Definition grid.h:564
double Get_Max(void)
Definition grid.cpp:1027
const CSG_Simple_Statistics & Get_Statistics(void)
Definition grid.cpp:1099
double Get_YMin(bool bCells=false) const
Definition grid.h:576
bool is_Cached(void) const
Definition grid.h:633
virtual bool Destroy(void)
Definition grid.cpp:379
double Get_Offset(void) const
Definition grid.cpp:428
double Get_Mean(void)
Definition grid.cpp:1017
TSG_Intersection is_Intersecting(const CSG_Rect &Extent) const
Definition grid.cpp:452
virtual int asInt(int x, int y, bool bScaled=true) const
Definition grid.h:785
double Get_Quantile(double Quantile, bool bFromHistogram=true)
Definition grid.cpp:1059
double Get_XMin(bool bCells=false) const
Definition grid.h:572
const CSG_Histogram & Get_Histogram(size_t nClasses=0)
Definition grid.cpp:1175
CSG_Vector Get_Row(int y) const
Definition grid.cpp:491
double Get_Cellsize(void) const
Definition grid.h:567
virtual ~CSG_Grid(void)
Definition grid.cpp:371
double Get_Scaling(void) const
Definition grid.cpp:422
virtual bool On_Update(void)
Definition grid.cpp:963
double Get_Percentile(double Percentile, bool bFromHistogram=true)
Definition grid.cpp:1082
virtual bool is_NoData(int x, int y) const
Definition grid.h:727
virtual void Set_Modified(bool bModified=true)
Definition grid.h:664
bool Set_Row(int y, const CSG_Vector &Values)
Definition grid.cpp:509
sLong Get_Sorted(sLong Position, bool bDown=true, bool bCheckNoData=true)
Definition grid.h:690
CSG_Grid(void)
Definition grid.cpp:136
virtual bool is_Valid(void) const
Definition grid.cpp:441
const CSG_String & Get_Unit(void) const
Definition grid.h:553
virtual double asDouble(sLong i, bool bScaled=true) const
Definition grid.h:793
double Get_Variance(void)
Definition grid.cpp:1042
double Get_Min(void)
Definition grid.cpp:1022
sLong Get_Data_Count(void)
Definition grid.cpp:1048
sLong Get_NCells(void) const
Definition grid.h:565
void Set_Scaling(double Scale=1., double Offset=0.)
Definition grid.cpp:406
bool Create(const CSG_Grid &Grid)
Definition grid.cpp:235
const CSG_Grid_System & Get_System(void) const
Definition grid.h:559
double Get_Value(double x, double y, CSG_Grid_Resampling Resampling=CSG_Grid_Resampling::Bicubic_2, bool bByteWise=false) const
Definition grid.cpp:539
void Set_Unit(const CSG_String &Unit)
Definition grid.cpp:400
virtual const CSG_Rect & Get_Extent(void)
Definition grid.h:561
int Get_NX(void) const
Definition grid.h:563
sLong Get_NoData_Count(void)
Definition grid.cpp:1053
bool is_InGrid(int x, int y, bool bCheckNoData=true) const
Definition grid.h:621
bool is_Scaled(void) const
Definition grid.h:587
double Get_StdDev(void)
Definition grid.cpp:1037
virtual void Set_Value(sLong i, double Value, bool bScaled=true)
Definition grid.h:843
bool is_Compatible(CSG_Grid *pGrid) const
Definition grid.cpp:468
double Get_Range(void)
Definition grid.cpp:1032
TSG_Data_Type Get_Type(void) const
Definition grid.h:547
bool Create(const CSG_Histogram &Histogram)
bool Update(void)
bool Create(void)
Definition metadata.cpp:73
bool Create(const CSG_Projection &Projection)
double Get_XMax(void) const
Definition geo_tools.h:506
double Get_XMin(void) const
Definition geo_tools.h:505
double Get_YMin(void) const
Definition geo_tools.h:507
double Get_YMax(void) const
Definition geo_tools.h:508
double Get_Maximum(void)
Definition mat_tools.h:749
bool Create(bool bHoldValues=false)
sLong Get_Count(void) const
Definition mat_tools.h:745
double Get_Minimum(void)
Definition mat_tools.h:748
static CSG_String Format(const char *Format,...)
const SG_Char * c_str(void) const
bool Create(const CSG_Vector &Vector)
int Get_N(void) const
Definition mat_tools.h:384
sLong SG_DataObject_Get_Max_Samples(void)
struct SSG_Point TSG_Point
TSG_Intersection
Definition geo_tools.h:101
struct SSG_Rect TSG_Rect
#define SG_GRID_HISTOGRAM_CLASSES_DEFAULT
Definition grid.cpp:1168
#define BiCubicSpline(d, v)
#define BILINEAR_ADD(ix, iy, d)
#define SET_BYTE(b, z)
#define SORT_SWAP(a, b)
CSG_Grid * SG_Create_Grid(void)
Definition grid.cpp:72
CSG_Grid_Resampling
Definition grid.h:156
double x
Definition geo_tools.h:129
double y
Definition geo_tools.h:129