RasterInMemory.cpp
Go to the documentation of this file.
1 #include "RasterExamples.h"
2 
3 // TerraLib
4 #include <terralib/memory.h>
5 #include <terralib/raster.h>
8 
9 // STL
10 #include <iostream>
11 #include <map>
12 
14 {
15  try
16  {
17  std::cout << "This test uses the memory driver." << std::endl << std::endl;
18 
19  std::map<std::string, std::string> rinfo;
20  rinfo["URI"] = TERRALIB_DATA_DIR "/geotiff/cbers2b_rgb342_crop.tif";
21 
23  te::rst::Raster* memraster = te::rst::RasterFactory::open(std::string("MEM"), rinfo, te::common::RWAccess);
24 
26 
27  std::cout << "band " << 0 << std::endl;
28  std::cout << " min val: " << *rs->at(0).m_minVal << std::endl;
29  std::cout << " max val: " << *rs->at(0).m_maxVal << std::endl;
30  std::cout << " std val: " << *rs->at(0).m_stdVal << std::endl;
31  std::cout << " mean val: " << *rs->at(0).m_meanVal << std::endl;
32 
33  std::cout << " histogram:" << std::endl;
34  std::cout << " " << *rs->at(0).m_minVal << std::endl;
35 
36  std::map<double, unsigned>::iterator it = rs->at(0).m_histogramR->begin();
37  while (it != rs->at(0).m_histogramR->end())
38  {
39  std::cout << " ";
40 
41  for (unsigned i = 0; i < it->second; i+=200)
42  std::cout << "*";
43 
44  std::cout << std::endl;
45 
46  ++it;
47  ++it;
48  ++it;
49  }
50  std::cout << " " << *rs->at(0).m_maxVal << std::endl;
51 
52  delete memraster;
53 
54  std::cout << "Done!" << std::endl << std::endl;
55  }
56  catch(const std::exception& e)
57  {
58  std::cout << std::endl << "An exception has occurred in RasterInMemory(): " << e.what() << std::endl;
59  }
60  catch(...)
61  {
62  std::cout << std::endl << "An unexpected exception has occurred in RasterInMemory()!" << std::endl;
63  }
64 
65 }
66 
void RasterInMemory()
An example to use the memory driver.
A raster class for memory.
This file contains include headers for the memory data source of TerraLib.
A singleton for keeping raster summaries (most statistics).
This is the abstract factory for Rasters.
static RasterSummaryManager & getInstance()
It returns a reference to the singleton instance.
An abstract class for raster data strucutures.
boost::ptr_vector< BandSummary > RasterSummary
RasterSummary is just a typedef of a boost::ptr_vector.
Definition: RasterSummary.h:44
These routines show how to use the raster module and the GDAL data source module. ...
Calculate all the summary types.
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.