All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Raster.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/gdal/Raster.cpp
22 
23  \brief This is a class that represents a GDAL Raster.
24  */
25 
26 // TerraLib
27 #include "../common/STLUtils.h"
28 #include "../common/StringUtils.h"
29 #include "../common/Translator.h"
30 #include "../datatype/Enums.h"
31 #include "../datatype/SimpleData.h"
32 #include "../geometry/Coord2D.h"
33 #include "../geometry/Envelope.h"
34 #include "../raster/Grid.h"
35 #include "../raster/RasterProperty.h"
36 #include "../raster/RasterFactory.h"
37 #include "../raster/Utils.h"
38 #include "../raster/Reprojection.h"
39 #include "../srs/Converter.h"
40 #include "Band.h"
41 #include "Exception.h"
42 #include "Raster.h"
43 #include "Utils.h"
44 
45 
46 // STL
47 #include <cassert>
48 #include <limits>
49 #include <stdint.h>
50 #include <map>
51 
52 // GDAL
53 #include <ogr_spatialref.h>
54 
55 // Boost
56 #include <boost/lexical_cast.hpp>
57 #include <boost/scoped_array.hpp>
58 
60  : te::rst::Raster(0),
61  m_gdataset(0),
62  m_deleter( 0 )
63 {
64 }
65 
67  : te::rst::Raster(0, p),
68  m_gdataset(0),
69  m_deleter( 0 )
70 {
71  GDALAllRegister();
72 
73  m_myURI = rinfo;
74 
78 
80 
81  if(m_gdataset == 0)
82  throw Exception(TE_TR("Data file can not be accessed."));
83 
85 
86  GetBands(this, m_bands);
87 }
88 
90  const std::vector<te::rst::BandProperty*>& bprops,
91  const std::map<std::string, std::string>& optParams,
93  : te::rst::Raster(grid, p),
94  m_deleter( 0 )
95 {
96  create(grid, bprops, optParams, 0, 0);
97 }
98 
99 // te::gdal::Raster::Raster(GDALDataset* gdataset, te::common::AccessPolicy p)
100 // : te::rst::Raster(0, p),
101 // m_gdataset(gdataset)
102 // {
103 // m_grid = GetGrid(m_gdataset);
104 //
105 // GetBands(this, m_bands);
106 //
107 // m_name = m_gdataset->GetDescription();
108 // }
109 
111  : te::rst::Raster(rhs),
112  m_gdataset(0),
113  m_deleter( 0 )
114 {
115  if(rhs.m_gdataset)
116  {
117 
118 
119  GDALDriver* driverPtr = rhs.m_gdataset->GetDriver();
120 
121  char** papszOptions = 0;
122 
123  m_gdataset = driverPtr->CreateCopy(rhs.m_gdataset->GetDescription(),
124  rhs.m_gdataset, 1, papszOptions,
125  NULL, NULL);
126 
127  m_myURI = m_gdataset->GetDescription();
128 
131 
132  GDALFlushCache(m_gdataset);
133 
135 
136  GetBands(this, m_bands);
137  }
138 }
139 
140 te::gdal::Raster::Raster( const unsigned int multiResolutionLevel,
141  const std::string& uRI, const te::common::AccessPolicy& policy )
142  : te::rst::Raster( 0, policy ),
143  m_deleter( 0 ),
144  m_myURI( uRI )
145 {
146  GDALAllRegister();
147 
149  ( IsSubDataSet( m_myURI ) || ( policy & te::common::WAccess ) ) ?
152 
154 
155  if(m_gdataset == 0)
156  throw Exception(TE_TR("Data file can not be accessed."));
157 
158  m_grid = GetGrid(m_gdataset, multiResolutionLevel);
159 
160  GetBands(this, multiResolutionLevel, m_bands );
161 }
162 
164 {
165  te::common::FreeContents(m_bands);
166 
167  if (m_gdataset)
168  {
169  std::string driverName = GetDriverName(m_gdataset->GetDescription());
170 
171  if ((driverName == "PNG" || driverName == "JPEG") &&
172  (m_policy == te::common::WAccess || m_policy == te::common::RWAccess))
173  {
174  char** papszOptions = 0;
175 
176  GDALDriver* driverPtr = GetGDALDriverManager()->GetDriverByName(driverName.c_str());
177 
178  GDALDataset* poDataset = driverPtr->CreateCopy(m_gdataset->GetDescription(),
179  m_gdataset, 0, papszOptions,
180  NULL, NULL);
181 
182  GDALClose(poDataset);
183  }
184 
185  GDALClose(m_gdataset);
186  }
187 
188  if(m_deleter)
189  {
190  // deleting who?
191  m_deleter = 0;
192  }
193 }
194 
195 void te::gdal::Raster::open(const std::map<std::string, std::string>& rinfo, te::common::AccessPolicy p)
196 {
197  std::map<std::string, std::string>::const_iterator it = rinfo.find("URI");
198 
199 // if URI is not specified, let's look for SOURCE
200  if(it == rinfo.end())
201  {
202  it = rinfo.find("SOURCE");
203 
204  if(it == rinfo.end())
205  throw Exception(TE_TR("At least the URI or SOURCE parameter must be informed!"));
206  }
207 
208  m_myURI = it->second;
209 
210  m_dsUseCounterPtr.reset( new DataSetUseCounter( GetParentDataSetName( m_myURI ),
213 
214  m_gdataset = GetRasterHandle(it->second, p);
215 
216  if(m_gdataset == 0)
217  throw Exception(TE_TR("Data file can not be accessed."));
218 
219  m_grid = GetGrid(m_gdataset);
220 
221  m_policy = p;
222 
223  GetBands(this, m_bands);
224 
225  m_name = m_gdataset->GetDescription();
226 }
227 
228 std::map<std::string, std::string> te::gdal::Raster::getInfo() const
229 {
230  std::map<std::string, std::string> info;
231 
232  info["URI"] = m_myURI;
233 
234  return info;
235 }
236 
238 {
239  return m_bands.size();
240 }
241 
242 int te::gdal::Raster::getBandDataType(std::size_t i) const
243 {
244  assert(i < m_bands.size());
245 
246  return m_bands[i]->getProperty()->getType();
247 }
248 
249 const te::rst::Band* te::gdal::Raster::getBand(std::size_t i) const
250 {
251  assert(i < m_bands.size());
252 
253  return m_bands[i];
254 }
255 
257 {
258  assert(i < m_bands.size());
259 
260  return m_bands[i];
261 }
262 
263 const te::rst::Band& te::gdal::Raster::operator[](std::size_t i) const
264 {
265  assert(i < m_bands.size());
266 
267  return *m_bands[i];
268 }
269 
271 {
272  assert(i < m_bands.size());
273 
274  return *m_bands[i];
275 }
276 
278 {
279  return m_gdataset;
280 }
281 
283 {
284  return new Raster(*this);
285 }
286 
288 {
290 
291  for (std::size_t b = 0; b < rhs.getNumberOfBands(); b++)
292  static_cast<te::gdal::Band*>(m_bands[b])->operator=(*static_cast<te::gdal::Band*>(rhs.m_bands[b]));
293 
294  return *this;
295 }
296 
297 te::rst::Raster* te::gdal::Raster::resample(int method, int scale, const std::map<std::string, std::string>& rinfo) const
298 {
299  assert(scale != 0);
300 
301  if (!(scale < 0 && method == 3))
302  return te::rst::Raster::resample(method, scale, rinfo);
303 
304 // create output parameters and raster
305  te::rst::Grid* grid = new te::rst::Grid(*getResampledGrid(scale));
306 
307  std::vector<te::rst::BandProperty*> bands;
308 
309  for (std::size_t b = 0; b < getNumberOfBands(); b++)
310  bands.push_back(new te::rst::BandProperty(*(getBand(b)->getProperty())));
311 
312  te::rst::Raster* rout = te::rst::RasterFactory::make(grid, bands, rinfo);
313 
314  int overviewScale[1] = { -scale };
315 
316  GDALDataset* inds = getGDALDataset();
317 
318  GDALDataset* outds = static_cast<te::gdal::Raster*>(rout)->getGDALDataset();
319 
320  int overviewIndex = -1;
321  for (int ov = 0; ov < inds->GetRasterBand(1)->GetOverviewCount(); ov++)
322  if (inds->GetRasterBand(1)->GetOverview(ov)->GetXSize() == outds->GetRasterBand(1)->GetXSize())
323  {
324  overviewIndex = ov;
325  ov = inds->GetRasterBand(1)->GetOverviewCount();
326  }
327 
328  if (overviewIndex == -1)
329  {
330  inds->BuildOverviews("CUBIC", 1, overviewScale, 0, NULL, GDALDummyProgress, NULL);
331 
332  overviewIndex = inds->GetRasterBand(1)->GetOverviewCount() - 1;
333  }
334 
335  GByte* buffer = (GByte*) malloc(outds->GetRasterXSize() * outds->GetRasterYSize() * sizeof(GByte*));
336 
337  double geoT[6];
338  outds->GetGeoTransform(geoT);
339  outds->SetGeoTransform(geoT);
340 
341  for (int b = 0; b < inds->GetRasterCount(); b++)
342  {
343  GDALRasterBand* outband = outds->GetRasterBand(b + 1);
344 
345  GDALRasterBand* inband = inds->GetRasterBand(b + 1)->GetOverview(overviewIndex);
346 
347  inband->RasterIO(GF_Read, 0, 0, inband->GetXSize(), inband->GetYSize(),
348  buffer, inband->GetXSize(), inband->GetYSize(), GDT_Byte, 0, 0);
349 
350  outband->RasterIO(GF_Write, 0, 0, inband->GetXSize(), inband->GetYSize(),
351  buffer, inband->GetXSize(), inband->GetYSize(), GDT_Byte, 0, 0);
352  }
353 
354  return rout;
355 }
356 
357 te::rst::Raster* te::gdal::Raster::transform(int srid, double llx, double lly, double urx, double ury, double resx, double resy, const std::map<std::string, std::string>& rinfo, int m) const
358 {
359 // if raster out is forced to be on memory, use other implementation
360  std::map<std::string, std::string>::const_iterator it = rinfo.find("USE_TERRALIB_REPROJECTION");
361 
362  if((it != rinfo.end()) &&
363  (te::common::Convert2UCase(it->second) == "TRUE"))
364  {
365  std::map<std::string, std::string> irinfo(rinfo);
366  std::map<std::string, std::string>::iterator iit = irinfo.find("USE_TERRALIB_REPROJECTION");
367  irinfo.erase(iit);
368 
369  return te::rst::Reproject(this, srid, llx, lly, urx, ury, resx, resy, irinfo, m);
370  }
371 
372 // otherwise, use GDAL Warp function
373  if (srid == getSRID())
374  return 0;
375 
376  if (!te::gdal::RecognizesSRID(srid))
377  throw Exception(TE_TR("Output SRID not recognized! Expecting a EPSG SRS id."));
378 
379  unsigned int ncols = getNumberOfColumns();
380  unsigned int nrows = getNumberOfRows();
381 
382  te::gm::Envelope* roi = new te::gm::Envelope(llx, lly, urx, ury);
383  if (!roi->isValid())
384  {
385  delete roi;
386 
387  roi = 0;
388  }
389  else
390  {
391  ncols = static_cast<unsigned int>((urx-llx)/getResolutionX())+1;
392 
393  nrows = static_cast<unsigned int>((ury-lly)/getResolutionY())+1;
394  }
395 
396  te::gm::Envelope* env = this->getExtent(srid, roi);
397  delete roi;
398 
399  if (resx == 0 || resy == 0) // maintain the same number of pixels
400  {
401  resx = env->getWidth()/ncols;
402 
403  resy = env->getHeight()/nrows;
404  }
405  else
406  {
407  ncols = static_cast<unsigned int>(env->getWidth()/resx) + 1;
408 
409  nrows = static_cast<unsigned int>(env->getHeight()/resy) + 1;
410  }
411 
412  te::rst::Grid* g = new te::rst::Grid(ncols, nrows, resx, resy, env, srid);
413 
414  // copy the band definitions
415  std::vector<te::rst::BandProperty*> bands;
416  for (unsigned int b=0; b<this->getNumberOfBands(); ++b)
417  {
418  te::rst::BandProperty* bb = new te::rst::BandProperty(*this->getBand(b)->getProperty());
419 
420  bands.push_back(bb);
421  }
422 
423 // create output raster
424  te::rst::Raster* rout = te::rst::RasterFactory::make(g, bands, rinfo);
425 
426  if (te::gdal::ReprojectRaster(this, rout))
427  {
428  delete rout;
429 
431  }
432 
433  delete rout;
434 
435  return 0;
436 }
437 
439 {
440  te::gdal::ReprojectRaster(this, outRaster);
441 }
442 
444  const std::vector<te::rst::BandProperty*> bands,
445  const std::map<std::string, std::string>& rinfo,
446  void* h, void (*deleter)(void*))
447 {
448  m_grid = g;
449 
450  m_deleter = deleter;
451 
452 // always assume that a created raster needs to be written
453  m_policy = te::common::RWAccess;
454 
455  if (h)
456  {
457  intptr_t buffaddress = (intptr_t) h;
458 
459  std::string memraster = "MEM:::DATAPOINTER=";
460  memraster += boost::lexical_cast<std::string>(buffaddress);
461  memraster += ",PIXELS=";
462  memraster += te::common::Convert2String(m_grid->getNumberOfColumns());
463  memraster += ",LINES=";
464  memraster += te::common::Convert2String(m_grid->getNumberOfRows());
465  memraster += ",BANDS=";
466  memraster += boost::lexical_cast<std::string>(bands.size());
467  memraster += ",DATATYPE=";
468  memraster += GDALGetDataTypeName(GetGDALDataType(bands[0]->getType()));
469 
470  m_gdataset = GetRasterHandle(memraster.c_str(), m_policy);
471  }
472  else
473  {
474  std::map<std::string, std::string>::const_iterator it = rinfo.find("URI");
475  if(it == rinfo.end())
476  {
477  it = rinfo.find("SOURCE");
478 
479  if(it == rinfo.end())
480  throw Exception(TE_TR("At least the URI or SOURCE parameter must be informed!"));
481  }
482 
483  m_myURI = it->second;
484 
485  m_dsUseCounterPtr.reset( new DataSetUseCounter( m_myURI, DataSetsManager::SingleAccessType ) );
486 
487  m_gdataset = te::gdal::CreateRaster(g, bands, rinfo);
488 
490 
491  if (!m_gdataset)
492  {
493  delete g;
494  g = 0;
495 
496  std::string mess = TE_TR("Raster couldn't be created:");
497  mess += m_name;
498  throw Exception(mess);
499  }
500 
501  GetBands(this, m_bands);
502  }
503 }
504 
505 bool te::gdal::Raster::createMultiResolution( const unsigned int levels,
506  const te::rst::InterpolationMethod interpMethod )
507 {
508  if( m_gdataset == 0 )
509  {
510  return false;
511  }
512  else
513  {
514  const DataSetsManager::AccessType oldAccessType = m_dsUseCounterPtr->getAccessType();
515 
516  if( m_dsUseCounterPtr->changeAccessType( te::gdal::DataSetsManager::SingleAccessType ) )
517  {
518  boost::scoped_array< int > overviewsIndexes( new int[ levels ] );
519  for( unsigned int overViewIdx = 0 ; overViewIdx < levels ; ++overViewIdx )
520  {
521  overviewsIndexes[ overViewIdx ] = overViewIdx + 1;
522  }
523 
524  // Clean old overviews
525 
526  m_gdataset->FlushCache();
527 
528  CPLErr returnValue = m_gdataset->BuildOverviews(
529  GetGDALRessamplingMethod( interpMethod ).c_str(),
530  (int)0,
531  0,
532  0,
533  NULL,
534  NULL,
535  NULL );
536 
537  m_gdataset->FlushCache();
538 
539  returnValue = m_gdataset->BuildOverviews(
540  GetGDALRessamplingMethod( interpMethod ).c_str(),
541  (int)levels,
542  overviewsIndexes.get(),
543  0,
544  NULL,
545  NULL,
546  NULL );
547 
548  m_gdataset->FlushCache();
549 
550  m_dsUseCounterPtr->changeAccessType( oldAccessType );
551 
552  if( returnValue == CE_Failure )
553  {
554  return false;
555  }
556  else
557  {
558  return true;
559  }
560  }
561  else
562  {
563  return false;
564  }
565  }
566 }
567 
569 {
570  if( m_gdataset == 0 )
571  {
572  return true;
573  }
574  else
575  {
576  if( m_gdataset->GetRasterCount() > 0 )
577  {
578  if( m_gdataset->GetRasterBand( 1 )->GetOverviewCount() > 0 )
579  {
580  CPLErr returnValue = m_gdataset->BuildOverviews(
582  (int)0,
583  0,
584  0,
585  NULL,
586  NULL,
587  NULL );
588 
589  m_gdataset->FlushCache();
590 
591  if( returnValue == CE_Failure )
592  {
593  return false;
594  }
595  else
596  {
597  return true;
598  }
599  }
600  else
601  {
602  return true;
603  }
604  }
605  else
606  {
607  return true;
608  }
609  }
610 }
611 
613 {
614  if( m_gdataset == 0 )
615  {
616  return 0;
617  }
618  else
619  {
620  if( m_gdataset->GetRasterCount() > 0 )
621  {
622  return (unsigned int)m_gdataset->GetRasterBand( 1 )->GetOverviewCount();
623  }
624  else
625  {
626  return 0;
627  }
628  }
629 }
630 
631 te::rst::Raster* te::gdal::Raster::getMultiResLevel( const unsigned int level ) const
632 {
633  if( m_gdataset == 0 )
634  {
635  return 0;
636  }
637  else
638  {
639  if( m_gdataset->GetRasterCount() > 0 )
640  {
641  if( level <= ((unsigned int)m_gdataset->GetRasterBand( 1 )->GetOverviewCount()) )
642  {
643  return new Raster( level, m_myURI, m_policy );
644  }
645  else
646  {
647  return 0;
648  }
649  }
650  else
651  {
652  return 0;
653  }
654  }
655 }
GDALDataset * getGDALDataset() const
Returns the raster GDAL handler.
Definition: Raster.cpp:277
void open(const std::map< std::string, std::string > &rinfo, te::common::AccessPolicy p=te::common::RAccess)
Opens a raster.
Definition: Raster.cpp:195
This is a class that represents a GDAL Raster.
GDALDataType GetGDALDataType(int tet)
It translates a TerraLib DataType to a GDAL DataType.
Definition: Utils.h:96
Near neighborhood interpolation method.
Definition: Enums.h:95
void GetBands(te::gdal::Raster *rst, std::vector< te::gdal::Band * > &bands)
Gets the list of bands from a GDAL dataset.
Definition: Utils.cpp:353
Utilitary functions to access GDAL and match some of its concepts to TerraLib concepts.
A raster band description.
Definition: BandProperty.h:61
This class represents Raster data.
Definition: Raster.h:61
const te::rst::Band & operator[](std::size_t i) const
Access band in i position.
Definition: Raster.cpp:263
It gives access to values in one band (dimension) of a raster.
virtual Raster * resample(int method, unsigned int drow, unsigned int dcolumn, unsigned int height, unsigned int width, unsigned int newheight, unsigned int newwidth, const std::map< std::string, std::string > &rinfo) const
Resample a subset of the raster, given a box.
Definition: Raster.cpp:565
std::string Convert2UCase(const std::string &value)
It converts a string to upper case.
Definition: StringUtils.h:163
double getWidth() const
It returns the envelope width.
Definition: Envelope.h:443
~Raster()
Virtual destructor.
Definition: Raster.cpp:163
te::rst::Raster * getMultiResLevel(const unsigned int level) const
Returns the required level of a multi-resolution pyramid or NULL if that level does not exists...
Definition: Raster.cpp:631
Raster & operator=(const Raster &rhs)
Definition: Raster.cpp:287
te::rst::Raster * resample(int method, int scale, const std::map< std::string, std::string > &rinfo) const
Resample raster.
Definition: Raster.cpp:297
te::rst::Raster * transform(int srid, double llx, double lly, double urx, double ury, double resx, double resy, const std::map< std::string, std::string > &rinfo, int m=0) const
Definition: Raster.cpp:357
bool removeMultiResolution()
Remove/Destroy a sub-sampled multi-resolution pyramid, if there is one.
Definition: Raster.cpp:568
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:347
InterpolationMethod
Allowed interpolation methods.
Definition: Enums.h:92
GDALDataset * m_gdataset
Gdal data set handler.
Definition: Raster.h:162
te::dt::AbstractData * clone() const
It returns a clone of this object.
Definition: Raster.cpp:282
std::string GetGDALRessamplingMethod(te::rst::InterpolationMethod interpolationMethod)
It translates a TerraLib interpolation method into a GDAL ressampling method name string...
Definition: Utils.h:190
This class represents raster band description.
Definition: Band.h:64
An exception class for the GDAL module.
Grid * m_grid
The spatial support for raster data.
Definition: Raster.h:681
AccessPolicy
Supported data access policies (can be used as bitfield).
Definition: Enums.h:40
GDALDataset * CreateRaster(te::rst::Grid *g, const std::vector< te::rst::BandProperty * > &bands, const std::map< std::string, std::string > &optParams)
Creates a raster data using GDAL.
Definition: Utils.cpp:639
std::auto_ptr< DataSetUseCounter > m_dsUseCounterPtr
Dataset use counter pointer.
Definition: Raster.h:166
GDALDataset * GetRasterHandle(std::string strAccessInfo, te::common::AccessPolicy policy=te::common::RAccess)
Get a handle to a raster file.
Definition: Utils.cpp:650
std::size_t getNumberOfBands() const
Returns the number of bands (dimension of cells attribute values) in the raster.
Definition: Raster.cpp:237
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
bool createMultiResolution(const unsigned int levels, const te::rst::InterpolationMethod interpMethod)
Create a sub-sampled multi-resolution pyramid.
Definition: Raster.cpp:505
An abstract class for raster data strucutures.
Definition: Raster.h:71
std::map< std::string, std::string > getInfo() const
It returns additional information about the raster.
Definition: Raster.cpp:228
std::string GetParentDataSetName(const std::string &subDataSetName)
It returns the parent dataset name from a Sub DataSet name.
Definition: Utils.cpp:882
std::string m_myURI
This instance URI;.
Definition: Raster.h:165
unsigned int getMultiResLevelsCount() const
Returns the current number of multi-resolution pyramid levels.
Definition: Raster.cpp:612
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:57
A raster band description.
Definition: Band.h:63
virtual Raster & operator=(const Raster &rhs)
Assignment operator.
Definition: Raster.cpp:406
int getBandDataType(std::size_t i) const
Returns the data type in a particular band (or dimension).
Definition: Raster.cpp:242
std::string GetDriverName(const std::string &dsName)
It returns the GDAL driver name associated to a data source name.
Definition: Utils.cpp:776
bool IsSubDataSet(const std::string &uri)
Returns true if the given URI is related to a sub-dataset.
Definition: Utils.cpp:859
bool ReprojectRaster(te::rst::Raster const *const rin, te::rst::Raster *rout)
Reprojects a raster to another SRS.
Definition: Utils.cpp:727
TERASTEREXPORT te::rst::Raster * Reproject(te::rst::Raster const *const rin, int srid, const std::map< std::string, std::string > &routinfo, int m=te::rst::NearestNeighbor)
Reprojects a raster to another SRS.
bool RecognizesSRID(unsigned int srid)
It returns true if GDAL recognizes the given SRS id.
Definition: Utils.cpp:716
static Raster * make()
It creates and returns an empty raster with default raster driver.
GDAL data set use counter.
std::vector< Band * > m_bands
The vector of available bands in the raster.
Definition: Raster.h:163
std::string Convert2String(boost::int16_t value)
It converts a short integer value to a string.
Definition: StringUtils.h:51
void create(te::rst::Grid *g, const std::vector< te::rst::BandProperty * > bands, const std::map< std::string, std::string > &rinfo, void *h, void(*deleter)(void *))
Definition: Raster.cpp:443
A rectified grid is the spatial support for raster data.
Definition: Grid.h:68
TEGDALEXPORT te::rst::Grid * GetGrid(GDALDataset *gds)
Gets the grid definition from a GDAL dataset.
Definition: Utils.cpp:104
void FreeContents(boost::unordered_map< K, V * > &m)
This function can be applied to a map of pointers. It will delete each pointer in the map...
Definition: BoostUtils.h:55
double getHeight() const
It returns the envelope height.
Definition: Envelope.h:448
te::common::AccessPolicy m_policy
The access policy, can be te::common::{NoAccess, RAccess, RWAccess, WAccess}.
Definition: Raster.h:682
bool isValid() const
It tells if the rectangle is valid or not.
Definition: Envelope.h:438
static Raster * open(const std::map< std::string, std::string > &rinfo, te::common::AccessPolicy p=te::common::RAccess)
It opens a raster with the given parameters and default raster driver.
const te::rst::Band * getBand(std::size_t i) const
Returns the raster i-th band.
Definition: Raster.cpp:249