37 #include <boost/filesystem.hpp>
40 #include <gdal_priv.h>
42 namespace fs = boost::filesystem;
80 errorMessage =
"Error in the number of bands!";
84 std::vector<te::rst::BandProperty*> bandProps;
97 for(
int unsigned i = 0; i < bandVec.size(); i++)
108 std::map<std::string, std::string> newRasterInfo;
109 newRasterInfo[
"URI"] = output;
119 std::vector<std::complex<double>> values;
133 for(
int unsigned b = 0; b < bandVec.size(); b++)
135 std::complex<double> value;
136 raster->
getValue(c, r, value, bandVec[b]);
138 newRaster->
setValue(c, r, value, bandVec[b]);
165 std::map<std::string, std::string> outInfo;
167 outInfo[
"URI"] = output;
183 output << raster->
toString() << std::endl << std::endl;
185 output <<
"Bands Type Informations:" << std::endl << std::endl;
197 output <<
"Block Informations:" << std::endl << std::endl;
212 std::string finalOutput =
"";
217 if(output == m_input)
219 errorMessage =
"Con not convert the raster for the same path and same extension!";
224 finalOutput = output;
227 else if(!extension.empty())
229 if(extension[0] !=
'.')
230 extension =
"." + extension;
232 fs::path temp(m_input);
233 temp.replace_extension(extension);
235 finalOutput = temp.string();
237 if(finalOutput == m_input)
239 errorMessage =
"Con not convert the raster for the same path and same extension!";
245 errorMessage =
"For this operations you must enter with the output path (\"--output\") or the output extension (\"--extension\")!";
253 if(!copyRaster(finalOutput, bandVec,
int(),errorMessage))
270 if(method < 1 || method > 3)
272 errorMessage =
"Method invalid!";
280 std::map<std::string, std::string> newRasterInfo;
281 newRasterInfo[
"URI"] = output;
283 raster->
resample(method, scale, newRasterInfo);
307 std::map<std::string, std::string> outInfo;
308 outInfo[
"URI"] = output;
309 raster->
trim(newRasterEnv, outInfo);
328 std::cout <<
"Supported Extensions" << std::endl;
329 std::cout <<
"--------------------" << std::endl << std::endl;
333 std::cout << it->first << std::endl;
335 std::map<std::string, std::string> map =
static_cast<te::rst::RasterFactory*
>(it->second)->getCapabilities();
337 std::cout <<
" " << map[
"supported_formats"] << std::endl << std::endl;
355 std::map<std::string, std::string> map;
virtual void setValue(unsigned int c, unsigned int r, const double value, std::size_t b=0)
Sets the attribute value in a band of a cell.
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.
te::gm::Envelope * getExtent()
Returns the geographic extension of the raster data.
Terralib Raster Manager Tool.
It contains the algorithm to reproject raster data.
A raster band description.
unsigned int getNumberOfColumns() const
Returns the raster number of columns.
int m_nblocksx
The number of blocks in x.
virtual const Band * getBand(std::size_t i) const =0
Returns the raster i-th band.
int m_nblocksy
The number of blocks in y.
virtual Raster * trim(const te::gm::Envelope *env, const std::map< std::string, std::string > &rinfo) const
Subsetting operation for trimming (cropping) the raster.
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.
static dictionary_type & getDictionary()
It returns a reference to the internal dictionary of concrete factories.
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.
std::map< TFACTORYKEY, TFACTORY *, TKEYCOMPARE >::const_iterator const_iterator
void Tokenize(const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters=" ")
It tokenizes a given string with a delimiter of your own choice.
An Envelope defines a 2D rectangular region.
An Envelope defines a 2D rectangular region.
An abstract class for raster data strucutures.
te::da::DataSourceCapabilities capabilities
unsigned int getNumberOfRows() const
Returns the raster number of rows.
BandProperty * getProperty()
Returns the band property.
int m_blkw
Block width (pixels).
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
Grid * getGrid()
It returns the raster grid.
std::map< TFACTORYKEY, TFACTORY *, TKEYCOMPARE >::const_iterator end() const
It returns an iterator to the end of the container.
virtual void getValue(unsigned int c, unsigned int r, double &value, std::size_t b=0) const
Returns the attribute value of a band of a cell.
std::string toString(void) const
It returns the data value in a string notation.
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.
std::map< TFACTORYKEY, TFACTORY *, TKEYCOMPARE >::const_iterator begin() const
It returns an iterator to the first stored factory.
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.
int getType() const
It returns the data type of the elements in the band.
std::string Convert2String(boost::int16_t value)
It converts a short integer value to a string.
This is the abstract factory for Rasters.
int m_blkh
Block height (pixels).
A rectified grid is the spatial support for raster data.
This class represents a dictionary of factories.