19 #include <gdal_priv.h> 25 std::cout <<
"This is a test to create a new raster (NDVI) based on raster arithmetic operations." << std::endl << std::endl;
28 std::map<std::string, std::string> sri, srndvi, srndvin, srden;
29 sri[
"URI"] = TERRALIB_DATA_DIR
"/geotiff/cbers2b_rgb342_crop.tif";
30 srndvi[
"URI"] = TERRALIB_DATA_DIR
"/geotiff/cbers2b_ndvi.tif";
31 srndvin[
"URI"] = TERRALIB_DATA_DIR
"/geotiff/cbers2b_ndvi_normalized.tif";
32 std::string base_path = TERRALIB_DATA_DIR
"/geotiff/";
39 std::vector<te::rst::BandProperty*> bdsden;
43 bdsden[0]->m_nblocksx = 1;
44 bdsden[0]->m_nblocksy = 1;
45 std::map<std::string, std::string> deninfo;
46 deninfo[
"FORCE_MEM_DRIVER"] =
"TRUE";
50 std::string connInfoRaster(
"file://");
51 connInfoRaster += base_path;
54 std::unique_ptr<te::da::DataSourceTransactor> tr = ds->getTransactor();
58 std::vector<te::rst::BandProperty*> bdsndvi;
69 std::complex<double> value;
76 *ndviBand -= *redBand;
85 *ndenBand += *redBand;
91 std::cout <<
"NDVI created:" << std::endl;
96 std::vector<te::rst::BandProperty*> bdsndvin;
107 std::cout <<
"Normalized NDVI created:" << std::endl;
118 std::cout <<
"Done!" << std::endl << std::endl;
120 catch(
const std::exception& e)
122 std::cout << std::endl <<
"An exception has occurred in ArithmetichWithRaster(): " << e.what() << std::endl;
126 std::cout << std::endl <<
"An unexpected exception has occurred in ArithmetichWithRaster()!" << std::endl;
unsigned int getNumberOfRows() const
Returns the grid number of rows.
static std::unique_ptr< DataSource > make(const std::string &driver, const te::core::URI &connInfo)
A raster band description.
unsigned int getNumberOfColumns() const
Returns the raster number of columns.
TERASTEREXPORT void Copy(const Raster &rin, Raster &rout)
Copies the pixel values from one raster to another.
static te::dt::Date ds(2010, 01, 01)
void ArithmeticWithRaster()
Creates a new raster based on raster arithmetic operations.
This class represents raster band description.
This is the abstract factory for Rasters.
virtual std::complex< double > getMaxValue(bool readall=false, unsigned int rs=0, unsigned int cs=0, unsigned int rf=0, unsigned int cf=0) const
It computes and returns the maximum occurring value in a window of the band.
void setValue(unsigned int c, unsigned int r, const double value)
Sets the cell attribute value.
An abstract class for raster data strucutures.
unsigned int getNumberOfRows() const
Returns the raster number of rows.
This file contains include headers for the TerraLib GDAL driver.
unsigned int getNumberOfColumns() const
Returns the grid number of columns.
A factory for data sources.
virtual const Band * getBand(std::size_t i) const =0
Returns the raster i-th band.
Grid * getGrid()
It returns the raster grid.
void getValue(unsigned int c, unsigned int r, double &value) const
Returns the cell attribute value.
std::string toString(void) const
It returns the data value in a string notation.
These routines show how to use the raster module and the GDAL data source module. ...
virtual std::complex< double > getMinValue(bool readall=false, unsigned int rs=0, unsigned int cs=0, unsigned int rf=0, unsigned int cf=0) const
It computes and returns the minimum occurring value in a window of the band.
static Raster * make()
It creates and returns an empty raster with default raster driver.
This file contains include headers for the TerraLib Common Runtime module.
This file contains include headers for the Vector Geometry model of TerraLib.
A rectified grid is the spatial support for raster data.
This file contains include headers for the Data Access module of TerraLib.
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.