17 #include <boost/filesystem.hpp> 23 std::string dataDirRaster(TERRALIB_DATA_DIR
"/geotiff");
24 std::string fileNameRaster =
"cbers2b_rgb342_crop.tif";
26 std::string connInfoRaster(
"file://" + dataDirRaster);
31 std::unique_ptr<te::da::DataSet> dsRaster = dsGDAL->getDataSet(fileNameRaster);
35 std::unique_ptr<te::rst::Raster> inputRst = dsRaster->getRaster(rpos);
39 std::string dataDirVector(TERRALIB_DATA_DIR
"/shape/shapeTeste.shp");
40 std::string fileNameVector =
"shapeTeste";
42 std::string connInfoVector(
"file://" + dataDirVector);
47 std::unique_ptr<te::da::DataSetType>dsTypeVector = dsOGR->getDataSetType(fileNameVector);
49 std::unique_ptr<te::da::DataSetTypeConverter> converterVector(
new te::da::DataSetTypeConverter(dsTypeVector.get(), dsOGR->getCapabilities(), dsOGR->getEncoding()));
52 std::vector<unsigned int> vecBands;
53 vecBands.push_back(0);
54 vecBands.push_back(1);
56 std::vector<te::stat::StatisticalSummary> vecStat;
62 std::string outputdataset =
"raster2vector";
63 std::string outputdatadir =
"/shp/" + outputdataset +
".shp";
65 boost::filesystem::path uri(TERRALIB_DATA_DIR + outputdatadir);
68 std::cout <<
"Output file already exists. Remove it or select a new name and try again.\n";
72 std::string dsinfo(
"file://" + uri.string());
75 outDataSource->open();
76 if (outDataSource->dataSetExists(outputdataset))
78 std::cout <<
"There is already a dataset with the requested name in the output data source. Remove it or select a new name and try again.\n";
86 dsOGR, fileNameVector, converterVector.get());
87 rst2vec->
setParams(vecBands, vecStat,
false,
false);
88 rst2vec->
setOutput(outDataSource, outputdataset);
100 std::cout <<
"Error: could not generate the operation.";
113 std::string dataDirRaster(TERRALIB_DATA_DIR
"/geotiff");
114 std::string fileNameRaster =
"cbers2b_rgb342_crop.tif";
116 std::string connInfoRaster(
"file://" + dataDirRaster);
120 std::unique_ptr<te::da::DataSet> dsRaster = dsGDAL->getDataSet(fileNameRaster);
124 std::unique_ptr<te::rst::Raster> inputRst = dsRaster->getRaster(rpos);
128 std::string dataDirVector(TERRALIB_DATA_DIR
"/shape/shapeTeste.shp");
129 std::string fileNameVector =
"shapeTeste";
131 std::string connInfoVector(
"file://" + dataDirVector);
136 std::unique_ptr<te::da::DataSetType>dsTypeVector = dsOGR->getDataSetType(fileNameVector);
138 std::unique_ptr<te::da::DataSetTypeConverter> converterVector(
new te::da::DataSetTypeConverter(dsTypeVector.get(), dsOGR->getCapabilities(), dsOGR->getEncoding()));
142 std::vector<unsigned int> vecBands;
143 vecBands.push_back(0);
144 vecBands.push_back(1);
146 std::vector<te::stat::StatisticalSummary> vecStat;
152 std::string connInfo(
"ppgsql://postgres:postgres@atlas.dpi.inpe.br:5433/testPostGIS");
155 outDataSource->open();
157 std::string outputdataset =
"raster2vector";
159 if (outDataSource->dataSetExists(outputdataset))
161 std::cout <<
"There is already a dataset with the requested name in the output data source. Remove it or select a new name and try again.\n";
169 dsOGR, fileNameVector, converterVector.get());
170 rst2vec->
setParams(vecBands, vecStat,
false,
false);
171 rst2vec->
setOutput(outDataSource, outputdataset);
178 res = rst2vec->
run();
183 std::cout <<
"Error: could not generate the operation.";
void setInput(te::rst::Raster *inRaster, te::da::DataSourcePtr inVectorDsrc, std::string inVectorName, te::da::DataSetTypeConverter *inVectorDsType, const te::da::ObjectIdSet *oidSet=0)
static std::unique_ptr< DataSource > make(const std::string &driver, const te::core::URI &connInfo)
static bool exists(const std::string &path)
Checks if a given path in UTF-8 exists.
boost::shared_ptr< DataSource > DataSourcePtr
bool RasterToVectorInPGIS()
void setOutput(te::da::DataSourcePtr outDsrc, std::string dsName)
An converter for DataSetType.
Raster to Vector processing.
A class for handling system files and paths.
bool RasterToVectorInSHP()
A factory for data sources.
void setParams(std::vector< unsigned int > bands, std::vector< te::stat::StatisticalSummary > statSum, bool iteratorByBox, bool texture)
This file contains include headers for the TerraLib Common Runtime module.
TEDATAACCESSEXPORT std::size_t GetFirstPropertyPos(const te::da::DataSet *dataset, int datatype)
This file contains include headers for the Data Access module of TerraLib.