VTK  9.3.20240328
vtkGDALRasterConverter.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
13 #ifndef vtkGDALRasterConverter_h
14 #define vtkGDALRasterConverter_h
15 
16 #include "vtkGeovisGDALModule.h" // For export macro
17 #include "vtkObject.h"
18 
19 // GDAL Forward declarations
20 class GDALDataset;
21 
22 VTK_ABI_NAMESPACE_BEGIN
23 // VTK Forward declarations
24 class vtkImageData;
25 class vtkUniformGrid;
26 
27 class VTKGEOVISGDAL_EXPORT vtkGDALRasterConverter : public vtkObject
28 {
29 public:
32  void PrintSelf(ostream& os, vtkIndent indent) override;
33 
35 
39  vtkSetMacro(NoDataValue, double);
40  vtkGetMacro(NoDataValue, double);
42 
48  GDALDataset* CreateGDALDataset(int xDim, int yDim, int vtkDataType, int numberOfBands);
49 
55  GDALDataset* CreateGDALDataset(vtkImageData* data, const char* mapProjection, int flipAxis[3]);
56 
60  void CopyBandInfo(GDALDataset* src, GDALDataset* dest);
61 
67  vtkUniformGrid* CreateVTKUniformGrid(GDALDataset* input);
68 
73  void SetGDALProjection(GDALDataset* dataset, const char* projectionString);
74 
79  GDALDataset* dataset, double origin[2], double spacing[2], int flipAxis[2]);
80 
84  void CopyNoDataValues(GDALDataset* src, GDALDataset* dest);
85 
89  void WriteTifFile(GDALDataset* dataset, VTK_FILEPATH const char* filename);
90 
96  bool FindDataRange(GDALDataset* dataset, int bandId, double* minValue, double* maxValue);
97 
98 protected:
101 
102  double NoDataValue;
103 
108  bool CopyToGDAL(vtkImageData* input, GDALDataset* output, int flipAxis[3]);
109 
110  class vtkGDALRasterConverterInternal;
111  vtkGDALRasterConverterInternal* Internal;
112 
113 private:
115  void operator=(const vtkGDALRasterConverter&) = delete;
116 };
117 
118 VTK_ABI_NAMESPACE_END
119 #endif // vtkGDALRasterConverter_h
Convert between VTK image representation and GDAL datasets.
GDALDataset * CreateGDALDataset(int xDim, int yDim, int vtkDataType, int numberOfBands)
Create GDAL dataset in memory.
void SetGDALProjection(GDALDataset *dataset, const char *projectionString)
Set projection on GDAL dataset, using any projection string recognized by GDAL.
vtkGDALRasterConverterInternal * Internal
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkUniformGrid * CreateVTKUniformGrid(GDALDataset *input)
Create vtkUniformGrid to match GDALDataset.
static vtkGDALRasterConverter * New()
void CopyNoDataValues(GDALDataset *src, GDALDataset *dest)
Copies NoDataValue info from 1st to 2nd dataset.
void CopyBandInfo(GDALDataset *src, GDALDataset *dest)
Copies color interpretation and color tables.
void WriteTifFile(GDALDataset *dataset, VTK_FILEPATH const char *filename)
Write GDALDataset to tiff file.
void SetGDALGeoTransform(GDALDataset *dataset, double origin[2], double spacing[2], int flipAxis[2])
Set geo-transform on GDAL dataset.
~vtkGDALRasterConverter() override
bool CopyToGDAL(vtkImageData *input, GDALDataset *output, int flipAxis[3])
Copies vtkImageData contents to GDALDataset GDALDataset must be initialized to same dimensions as vtk...
bool FindDataRange(GDALDataset *dataset, int bandId, double *minValue, double *maxValue)
Traverse values in specified band to find min/max.
GDALDataset * CreateGDALDataset(vtkImageData *data, const char *mapProjection, int flipAxis[3])
Create GDALDataset to match vtkImageData.
topologically and geometrically regular array of data
Definition: vtkImageData.h:155
a simple class to control print indentation
Definition: vtkIndent.h:108
abstract base class for most VTK objects
Definition: vtkObject.h:161
image data with blanking
@ spacing
Definition: vtkX3D.h:481
@ data
Definition: vtkX3D.h:315
#define VTK_FILEPATH