All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Utils.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/raster/Utils.cpp
22 
23  \brief Utility functions for the raster module.
24 */
25 
26 // TerraLib
27 #include "../datatype/Enums.h"
28 #include "../geometry/Coord2D.h"
29 #include "BandIterator.h"
30 #include "Exception.h"
31 #include "PositionIterator.h"
32 #include "RasterFactory.h"
33 #include "Utils.h"
34 
35 // Boost
36 #include <boost/cstdint.hpp>
37 #include <boost/random.hpp>
38 #include <boost/random/uniform_int_distribution.hpp>
39 
40 // STL
41 #include <cassert>
42 #include <limits>
43 #include <vector>
44 
45 static int sg_pixelSize[] = { 0,
46  0,
47  0,
48  sizeof(char) * 8,
49  sizeof(unsigned char),
50  sizeof(boost::int16_t),
51  sizeof(boost::uint16_t),
52  sizeof(boost::int32_t),
53  sizeof(boost::uint32_t),
54  sizeof(boost::int64_t),
55  sizeof(boost::uint64_t),
56  sizeof(bool),
57  sizeof(float),
58  sizeof(double),
59  0,
60  0,
61  0,
62  0,
63  0,
64  0,
65  0,
66  0,
67  0,
68  sizeof(boost::int16_t) * 2,
69  sizeof(boost::int32_t) * 2,
70  sizeof(float) * 2,
71  sizeof(double) * 2,
72  0,
73  0,
74  0,
75  sizeof(unsigned char), // 4bits = 4/8 sizeof(unsigned char)
76  sizeof(unsigned char), // 2bits = 2/8 sizeof(unsigned char)
77  sizeof(unsigned char) // 1bit = 1/8 sizeof(unsigned char)
78  };
79 
80 int te::rst::GetPixelSize(int datatype)
81 {
82  return sg_pixelSize[datatype];
83 }
84 
85 std::vector<te::rst::BandProperty*> te::rst::GetBandProperties(const std::map<std::string, std::string>& rinfo)
86 {
87  std::size_t nBands;
88  int tBands;
89  std::vector<te::rst::BandProperty*> bprops;
90 
91  std::map<std::string, std::string>::const_iterator it = rinfo.find("NBANDS");
92 
93  if(it == rinfo.end())
94  throw Exception(("Number of bands must be set!"));
95 
96  nBands = atoi(it->second.c_str());
97 
98  it = rinfo.find("BANDSTYPE");
99 
100  if(it == rinfo.end())
101  throw Exception(("Data type of bands must be set!"));
102 
103  tBands = atoi(it->second.c_str());
104 
105  for (std::size_t b = 0; b < nBands; b++)
106  bprops.push_back(new te::rst::BandProperty(b, tBands));
107 
108  return bprops;
109 }
110 
111 te::rst::Grid* te::rst::GetGrid(const std::map<std::string, std::string>& rinfo)
112 {
113  unsigned nCols, nRows;
114  double resX = 1.0, resY = 1.0, ulX =0.0, ulY=0.0;
115  int srid = TE_UNKNOWN_SRS;
116  te::gm::Coord2D* ulc;
117 
118  std::map<std::string, std::string>::const_iterator it = rinfo.find("NCOLS");
119 
120  if(it == rinfo.end())
121  throw Exception(("Number of columns must be set!"));
122 
123  nCols = atoi(it->second.c_str());
124 
125  it = rinfo.find("NROWS");
126 
127  if(it == rinfo.end())
128  throw Exception(("Number of rows must be set!"));
129 
130  nRows = atoi(it->second.c_str());
131 
132  it = rinfo.find("RESX");
133  if(it != rinfo.end())
134  resX = atof(it->second.c_str());
135 
136  it = rinfo.find("RESY");
137  if(it != rinfo.end())
138  resY = atof(it->second.c_str());
139 
140  it = rinfo.find("SRID");
141  if(it != rinfo.end())
142  srid = atoi(it->second.c_str());
143 
144  it = rinfo.find("ULX");
145  if(it != rinfo.end())
146  ulX = atof(it->second.c_str());
147 
148  it = rinfo.find("ULY");
149  if(it != rinfo.end())
150  ulY = atof(it->second.c_str());
151 
152  ulc = new te::gm::Coord2D(ulX, ulY);
153 
154  return (new te::rst::Grid(nCols, nRows, resX, resY, ulc, srid));
155 }
156 
158 {
159  assert(rin.getNumberOfBands() == rout.getNumberOfBands());
161 
162  const std::size_t nbands = rin.getNumberOfBands();
163  const unsigned int nRows = rin.getNumberOfRows();
164  const unsigned int nCols = rin.getNumberOfColumns();
165  unsigned int row = 0;
166  unsigned int col = 0;
167  std::complex< double > value;
168 
169  for(std::size_t b = 0; b < nbands; b++)
170  {
171  if(rin.getBand(b)->getProperty()->getType() == rout.getBand(b)->getProperty()->getType())
172  {
173  Copy(*rin.getBand(b), *rout.getBand(b));
174  }
175  else
176  {
177  const te::rst::Band& bin = *rin.getBand(b);
178  te::rst::Band& bout = *rout.getBand(b);
179 
180  for(row = 0 ; row < nRows ; ++row)
181  for(col = 0 ; col < nCols ; ++col)
182  {
183  bin.getValue(col, row, value);
184 
185  bout.setValue(col, row, value);
186  }
187  }
188  }
189 }
190 
192 {
193  assert(*bin.getRaster()->getGrid() == *bout.getRaster()->getGrid());
194 
195 // when both bands have the same data type
196  if (bin.getProperty()->getType() == bout.getProperty()->getType())
197  {
198  unsigned char* buffer = new unsigned char[bin.getBlockSize()];
199 
200  int nblocksx = bin.getProperty()->m_nblocksx;
201  int nblocksy = bin.getProperty()->m_nblocksy;
202 
203  const int blkw = bin.getProperty()->m_blkw;
204  const int blkh = bin.getProperty()->m_blkh;
205 
206  // when both rasters have the same block size, copy the entire blocks from in to out
207  if((blkw == bout.getProperty()->m_blkw) &&
208  (blkh == bout.getProperty()->m_blkh))
209  {
210  for(int y = 0; y < nblocksy; ++y)
211  {
212  for(int x = 0; x < nblocksx; ++x)
213  {
214  bin.read(x, y, buffer);
215  bout.write(x, y, buffer);
216  }
217  }
218  }
219  // get all values from input block, and copy pixel by pixel to the output band
220  else
221  {
222  std::complex<double> value;
223 
224  const unsigned int ncols = bin.getRaster()->getNumberOfColumns();
225  const unsigned int nrows = bin.getRaster()->getNumberOfRows();
226 
227  for(int y = 0; y < nblocksy; ++y)
228  {
229  for(int x = 0; x < nblocksx; ++x)
230  {
231  unsigned int w = blkw * (x + 1);
232 
233  w = w > ncols ? ncols : w;
234 
235  unsigned int h = blkh * (y + 1);
236 
237  h = h > nrows ? nrows : h;
238 
239  for(int r = blkh * y; r < (int)h; ++r)
240  {
241  for(int c = blkw * x; c < (int)w; ++c)
242  {
243  bin.getValue(c, r, value);
244 
245  bout.setValue(c, r, value);
246  }
247  }
248  }
249  }
250  }
251 
252  delete [] buffer;
253  }
254 // if bands have different data types, use iterator
255  else
256  {
258 
260 
261  while(rit != ritend)
262  {
263  bout.setValue(rit.getColumn(), rit.getRow(), *rit);
264 
265  ++rit;
266  }
267  }
268 }
269 
270 void te::rst::Copy(unsigned int drow, unsigned int dcolumn, unsigned int height, unsigned int width, const Raster& rin, Raster& rout)
271 {
272  assert(drow + height <= rin.getNumberOfRows());
273  assert(dcolumn + width <= rin.getNumberOfColumns());
274 
275 // define variables for interpolation
276  std::vector<std::complex<double> > v;
277 
278  for (unsigned r = drow; r < drow + height; r++)
279  {
280  for (unsigned c = dcolumn; c < dcolumn + width; c++)
281  {
282  te::gm::Coord2D inputGeo = rin.getGrid()->gridToGeo(c, r);
283 
284  te::gm::Coord2D outputGrid = rout.getGrid()->geoToGrid(inputGeo.x, inputGeo.y);
285 
286  int x = Round(outputGrid.x);
287  int y = Round(outputGrid.y);
288 
289  if((x >=0 && x < (int)rout.getNumberOfColumns()) && (y >=0 && y < (int)rout.getNumberOfRows()))
290  {
291  rin.getValues(c, r, v);
292  rout.setValues(x, y, v);
293  }
294  }
295  }
296 }
297 
298 int te::rst::Round(double val)
299 {
300  if (val>=0)
301  return (int)(val+.5);
302  else
303  return (int)(val-.5);
304 }
305 
307  const std::string& uri,
308  const std::string &rType)
309 {
310  std::map<std::string, std::string> rasterInfo;
311  rasterInfo["URI"] = uri;
312 
313  std::vector<te::rst::BandProperty*> bandsProperties;
314 
315  unsigned int bandIndex = 0;
316 
317  for(bandIndex = 0; bandIndex < rin.getNumberOfBands(); ++bandIndex)
318  {
319  bandsProperties.push_back(new te::rst::BandProperty(*(rin.getBand(bandIndex )->getProperty())));
320  }
321 
322  te::rst::RasterPtr outRasterPtr;
323 
324  outRasterPtr.reset( te::rst::RasterFactory::make( rType, new te::rst::Grid(*(rin.getGrid())), bandsProperties, rasterInfo, 0, 0));
325 
326  if(outRasterPtr.get() == 0)
327  return outRasterPtr;
328 
329  Copy(rin, *outRasterPtr);
330 
331  return outRasterPtr;
332 }
333 
334 void te::rst::GetDataTypeRanges( const int& dataType, double& min, double& max )
335 {
336  switch( dataType )
337  {
338  case te::dt::R4BITS_TYPE:
339  min = 0;
340  max = 15;
341  break;
342 
343  case te::dt::R2BITS_TYPE:
344  min = 0;
345  max = 3;
346  break;
347 
348  case te::dt::R1BIT_TYPE:
349  min = 0;
350  max = 1;
351  break;
352 
353  case te::dt::UCHAR_TYPE:
354  min = 0;
355  max = 255;
356  break;
357 
358  case te::dt::CHAR_TYPE:
359  min = -127;
360  max = 127;
361  break;
362 
363  case te::dt::UINT16_TYPE:
364  min = 0;
365  max = (double)std::numeric_limits<unsigned short int>::max();
366  break;
367 
368  case te::dt::INT16_TYPE:
369  min = (double)std::numeric_limits<short int>::min();
370  max = (double)std::numeric_limits<short int>::max();
371  break;
372 
373  case te::dt::UINT32_TYPE:
374  min = 0;
375  max = (double)std::numeric_limits<unsigned int>::max();
376  break;
377 
378  case te::dt::INT32_TYPE:
379  min = (double)std::numeric_limits<int>::min();
380  max = (double)std::numeric_limits<int>::max();
381  break;
382 
383  case te::dt::FLOAT_TYPE:
384  min = -(double)std::numeric_limits< float >::max();
385  max = (double)std::numeric_limits< float >::max();
386  break;
387 
388  case te::dt::DOUBLE_TYPE:
389  min = -std::numeric_limits< double >::max();
390  max = std::numeric_limits< double >::max();
391  break;
392 
393  case te::dt::CINT16_TYPE:
394  min = (double)std::numeric_limits<short int>::min();
395  max = (double)std::numeric_limits<short int>::max();
396  break;
397 
398  case te::dt::CINT32_TYPE:
399  min = (double)std::numeric_limits<int>::min();
400  max = (double)std::numeric_limits<int>::max();
401  break;
402 
403  case te::dt::CFLOAT_TYPE:
404  min = -(double)std::numeric_limits< float >::max();
405  max = (double)std::numeric_limits< float >::max();
406  break;
407 
409  min = -std::numeric_limits< double >::max();
410  max = std::numeric_limits< double >::max();
411  break;
412 
413  default:
414  throw te::rst::Exception("Invalid data type");
415  }
416 }
417 
418 void te::rst::FillRaster(te::rst::Raster* rin, const std::complex<double>& value)
419 {
420  for (unsigned int b = 0; b < rin->getNumberOfBands(); b++)
421  te::rst::FillBand(rin->getBand(b), value);
422 }
423 
424 void te::rst::FillBand(te::rst::Band* bin, const std::complex<double>& value)
425 {
426  for (unsigned int r = 0; r < bin->getRaster()->getNumberOfRows(); r++)
427  for (unsigned int c = 0; c < bin->getRaster()->getNumberOfColumns(); c++)
428  bin->setValue(c, r, value);
429 }
430 
431 te::rst::RasterPtr te::rst::CropRaster(const te::rst::Raster& rin, const te::gm::Polygon& pin, const std::map<std::string, std::string>& rinfo, const std::string& rType)
432 {
433  std::vector<te::rst::BandProperty*> bprops;
434  for(unsigned int b = 0; b < rin.getNumberOfBands(); b++)
435  {
436  bprops.push_back(new te::rst::BandProperty(*(rin.getBand(b)->getProperty())));
437  }
438 
439 // define new grid
440  te::gm::Envelope* envelope = new te::gm::Envelope(*pin.getMBR());
441  te::rst::Grid* grid = new te::rst::Grid(rin.getResolutionX(),
442  rin.getResolutionY(),
443  envelope,
444  rin.getSRID());
445 // create the output raster
446  te::rst::RasterPtr rout;
447  rout.reset(te::rst::RasterFactory::make(rType, grid, bprops, rinfo, 0, 0));
448  if(rout.get() == 0)
449  return rout;
450 
451 // fill bands with no data
452  for (unsigned int b = 0; b < rin.getNumberOfBands(); b++)
453  {
454  double noDataValue = rin.getBand(b)->getProperty()->m_noDataValue;
455  FillBand(rout->getBand(b), noDataValue);
456  }
457 
458 // make crop using polygon iterator
459  te::gm::Coord2D geoCoord;
460  te::gm::Coord2D gridCoord;
463  std::vector<double> pixels(rin.getNumberOfBands());
464  unsigned int gridColumn;
465  unsigned int gridRow;
466  while (it != itend)
467  {
468  for (unsigned int b = 0; b < rout->getNumberOfBands(); b++)
469  pixels[b] = (*it)[b];
470  geoCoord = rin.getGrid()->gridToGeo(it.getColumn(), it.getRow());
471  ++it;
472  gridCoord = rout->getGrid()->geoToGrid(geoCoord.x, geoCoord.y);
473  gridColumn = (unsigned int) gridCoord.x;
474  gridRow = (unsigned int) gridCoord.y;
475  if (gridColumn >= rout->getNumberOfColumns())
476  continue;
477  if (gridRow >= rout->getNumberOfRows())
478  continue;
479  rout->setValues(gridColumn, gridRow, pixels);
480  }
481 
482  return rout;
483 }
484 
485 std::vector<te::gm::Point*> te::rst::GetRandomPointsInRaster(const te::rst::Raster& inputRaster, unsigned int numberOfPoints)
486 {
487  std::vector<te::gm::Point*> randomPoints;
488  double randX;
489  double randY;
490 
491  boost::random::mt19937 generator((boost::random::mt19937::result_type) time(0));
492  boost::random::uniform_int_distribution<> random_rows(0, inputRaster.getNumberOfRows() - 1);
493  boost::random::uniform_int_distribution<> random_columns(0, inputRaster.getNumberOfColumns() - 1);
494 
495  for (unsigned int p = 0; p < numberOfPoints; p++)
496  {
497  inputRaster.getGrid()->gridToGeo(random_columns(generator), random_rows(generator), randX, randY);
498  randomPoints.push_back(new te::gm::Point(randX, randY, inputRaster.getSRID()));
499  }
500 
501  return randomPoints;
502 }
503 
505 {
506  if(ci == te::rst::UndefCInt)
507  return TE_TR("Undefined");
508  else if(ci == te::rst::GrayIdxCInt)
509  return TE_TR("Gray");
510  else if(ci == te::rst::PaletteIdxCInt)
511  return TE_TR("Palette");
512  else if(ci == te::rst::RedCInt)
513  return TE_TR("Red");
514  else if(ci == te::rst::GreenCInt)
515  return TE_TR("Green");
516  else if(ci == te::rst::BlueCInt)
517  return TE_TR("Blue");
518  else if(ci == te::rst::AlphaCInt)
519  return TE_TR("Alpha");
520  else if(ci == te::rst::HueCInt)
521  return TE_TR("Hue");
522  else if(ci == te::rst::SatCInt)
523  return TE_TR("Saturation");
524  else if(ci == te::rst::LigCInt)
525  return TE_TR("Lightness");
526  else if(ci == te::rst::CyanCInt)
527  return TE_TR("Cyan");
528  else if(ci == te::rst::MagentaCInt)
529  return TE_TR("Magenta");
530  else if(ci == te::rst::YellowCInt)
531  return TE_TR("Yellow");
532  else if(ci == te::rst::KeyCInt)
533  return TE_TR("Key");
534  else if(ci == te::rst::YCInt)
535  return TE_TR("Y");
536  else if(ci == te::rst::CbCInt)
537  return TE_TR("Cb");
538  else if(ci == te::rst::CrCInt)
539  return TE_TR("Cr");
540 
541  return "";
542 }
543 
545 {
546  if(pi == te::rst::UndefPalInt)
547  return TE_TR("Undefined");
548  else if(pi == te::rst::GrayPalInt)
549  return TE_TR("Gray");
550  else if(pi == te::rst::RGBPalInt)
551  return TE_TR("RGB");
552  else if(pi == te::rst::CMYKPalInt)
553  return TE_TR("CMYK");
554  else if(pi == te::rst::HSLPalInt)
555  return TE_TR("HSL");
556 
557  return "";
558 }
TERASTEREXPORT te::rst::RasterPtr CropRaster(const te::rst::Raster &rin, const te::gm::Polygon &pin, const std::map< std::string, std::string > &rinfo, const std::string &rType=std::string("GDAL"))
Creates a raster crop using a polygon delimiter.
Definition: Utils.cpp:431
HSL indexed palette interpretation.
Definition: Enums.h:86
virtual void setValues(unsigned int c, unsigned int r, const std::vector< double > &values)
Sets the imaginary attribute values in all complex bands of a cell.
Definition: Raster.cpp:286
unsigned int getRow() const
Returns the current row in iterator.
Definition: BandIterator.h:389
Palette indexes color interpretation.
Definition: Enums.h:58
Hue channel color interpretation.
Definition: Enums.h:63
Alpha channel color interpretation.
Definition: Enums.h:62
TERASTEREXPORT void FillBand(te::rst::Band *bin, const std::complex< double > &value)
Fill a Raster Band with provided value.
Definition: Utils.cpp:424
double y
y-coordinate.
Definition: Coord2D.h:114
TERASTEREXPORT void GetDataTypeRanges(const int &dataType, double &min, double &max)
Return the values range of a given data type.
Definition: Utils.cpp:334
Index into a lookup table.
Definition: Enums.h:57
unsigned int getColumn() const
Returns the current column in iterator.
Definition: BandIterator.h:394
virtual void getValue(unsigned int c, unsigned int r, double &value) const =0
Returns the cell attribute value.
Lightness color interpretation.
Definition: Enums.h:65
ColorInterp
Color model component use.
Definition: Enums.h:54
A raster band description.
Definition: BandProperty.h:61
double x
x-coordinate.
Definition: Coord2D.h:113
RGB indexed palette interpretation.
Definition: Enums.h:84
unsigned int getNumberOfColumns() const
Returns the raster number of columns.
Definition: Raster.cpp:213
int m_nblocksx
The number of blocks in x.
Definition: BandProperty.h:145
virtual const Band * getBand(std::size_t i) const =0
Returns the raster i-th band.
Gray indexed palette interpretation.
Definition: Enums.h:83
void Copy(const std::vector< T * > &src, std::vector< T * > &dst)
This function can be applied to a vector of pointers. It will copy element by element through its cop...
Definition: STLUtils.h:255
TERASTEREXPORT te::rst::RasterPtr CreateCopy(const te::rst::Raster &rin, const std::string &uri, const std::string &rType=std::string("GDAL"))
Create a new raster from existing one.
Definition: Utils.cpp:306
int m_nblocksy
The number of blocks in y.
Definition: BandProperty.h:146
virtual void getValues(unsigned int c, unsigned int r, std::vector< double > &values) const
Returns the imaginary attribute values in all complex bands of a cell.
Definition: Raster.cpp:258
This class implements the strategy to iterate with spatial restriction, the iteration occurs inside a...
TERASTEREXPORT void Copy(const Raster &rin, Raster &rout)
Copies the pixel values from one raster to another.
Definition: Utils.cpp:157
static int sg_pixelSize[]
Definition: Utils.cpp:45
Red channel color interpretation.
Definition: Enums.h:59
virtual void read(int x, int y, void *buffer) const =0
It reads a data block to the specified buffer.
TERASTEREXPORT void FillRaster(te::rst::Raster *rin, const std::complex< double > &value)
Fill a Raster with provided value (all bands).
Definition: Utils.cpp:418
unsigned int getRow() const
Returns the current row in iterator.
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
double m_noDataValue
Value to indicate elements where there is no data, default is std::numeric_limits::max().
Definition: BandProperty.h:136
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:347
Cyan color interpretation.
Definition: Enums.h:66
TERASTEREXPORT std::string ConvertColorInterpTypeToString(const te::rst::ColorInterp &ci)
Function used to convert from a Color Interp Enum to a string.
Definition: Utils.cpp:504
This class implements an iterator to "navigate" over a single band (const).
Definition: BandIterator.h:211
void geoToGrid(const double &x, const double &y, double &col, double &row) const
Get the grid point associated to a spatial location.
Definition: Grid.cpp:307
static ConstBandIterator begin(const Band *b)
Returns an iterator referring to the first value of the band.
Definition: BandIterator.h:592
te::common::AccessPolicy getAccessPolicy() const
Returns the raster access policy.
Definition: Raster.cpp:89
boost::shared_ptr< Raster > RasterPtr
Definition: Raster.h:685
An exception class for the Raster module.
static PolygonIterator end(const te::rst::Raster *r, const te::gm::Polygon *p)
Returns an iterator referring to after the end of the iterator.
A point with x and y coordinate values.
Definition: Point.h:50
TERASTEREXPORT int Round(double val)
Round a double value to a integer value.
Definition: Utils.cpp:298
YCbCr Cr Band color interpretation.
Definition: Enums.h:72
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib.
Definition: Config.h:44
An abstract class for raster data strucutures.
Definition: Raster.h:71
unsigned int getNumberOfRows() const
Returns the raster number of rows.
Definition: Raster.cpp:208
BandProperty * getProperty()
Returns the band property.
Definition: Band.cpp:428
It implements an iterator to "navigate" over a single band (const or not const).
int m_blkw
Block width (pixels).
Definition: BandProperty.h:143
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
Utility functions for the raster module.
virtual Raster * getRaster() const =0
Returns the associated raster.
double getResolutionX() const
Returns the raster horizontal (x-axis) resolution.
Definition: Raster.cpp:218
virtual void write(int x, int y, void *buffer)=0
It writes a data block from the specified buffer.
No color interpretation is associated with the band.
Definition: Enums.h:56
A raster band description.
Definition: Band.h:63
Undefined palette interpretation.
Definition: Enums.h:82
Grid * getGrid()
It returns the raster grid.
Definition: Raster.cpp:94
TERASTEREXPORT int GetPixelSize(int datatype)
Returns the byte size of a given datatype.
Definition: Utils.cpp:80
TEDATAACCESSEXPORT double Round(const double &value, const size_t &precision)
It gets the round value.
Definition: Utils.cpp:1329
Key (black) color interpretation.
Definition: Enums.h:69
Yellow color interpretation.
Definition: Enums.h:68
virtual void setValue(unsigned int c, unsigned int r, const double value)=0
Sets the cell attribute value.
int getSRID() const
Returns the raster spatial reference system identifier.
Definition: Raster.cpp:203
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:50
TERASTEREXPORT Grid * GetGrid(const std::map< std::string, std::string > &rinfo)
Returns a grid based on a given raster info.
Definition: Utils.cpp:111
static PolygonIterator begin(const te::rst::Raster *r, const te::gm::Polygon *p)
Returns an iterator referring to the first value of the band.
static Raster * make()
It creates and returns an empty raster with default raster driver.
TERASTEREXPORT std::string ConvertPalleteInterpTypeToString(const te::rst::PaletteInterpretation &pi)
Function used to convert from a Pallete Interp Enum to a string.
Definition: Utils.cpp:544
void gridToGeo(const double &col, const double &row, double &x, double &y) const
Get the spatial location of a grid point.
Definition: Grid.cpp:301
double getResolutionY() const
Returns the raster vertical (y-axis) resolution.
Definition: Raster.cpp:223
TERASTEREXPORT std::vector< te::gm::Point * > GetRandomPointsInRaster(const te::rst::Raster &inputRaster, unsigned int numberOfPoints=1000)
Creates a vector of random positions (points) inside the raster.
Definition: Utils.cpp:485
YCbCr Y Band color interpretation.
Definition: Enums.h:70
int getType() const
It returns the data type of the elements in the band.
Definition: BandProperty.h:113
CMYK indexed palette interpretation.
Definition: Enums.h:85
This is the abstract factory for Rasters.
Saturation color interpretation.
Definition: Enums.h:64
int m_blkh
Block height (pixels).
Definition: BandProperty.h:144
Blue channel color interpretation.
Definition: Enums.h:61
PaletteInterpretation
Palette interpratation types.
Definition: Enums.h:80
unsigned int getColumn() const
Returns the current column in iterator.
A rectified grid is the spatial support for raster data.
Definition: Grid.h:68
Green channel color interpretation.
Definition: Enums.h:60
virtual int getBlockSize() const
It returns the number of bytes ocuppied by a data block.
Definition: Band.cpp:630
const Envelope * getMBR() const
It returns the minimum bounding rectangle for the geometry in an internal representation.
Definition: Geometry.cpp:104
Magenta color interpretation.
Definition: Enums.h:67
YCbCr Cb Band color interpretation.
Definition: Enums.h:71
TERASTEREXPORT std::vector< BandProperty * > GetBandProperties(const std::map< std::string, std::string > &rinfo)
Returns a vector of band properties, based on a given raster info.
Definition: Utils.cpp:85
static ConstBandIterator end(const Band *b)
Returns an iterator referring to after the end of the iterator.
Definition: BandIterator.h:597