18 std::cout <<
"This is a test to open a shapefile and save some polygons in a raster file." << std::endl << std::endl;
20 std::string ogrInfo(
"file://");
21 ogrInfo += TERRALIB_DATA_DIR
"/shape/munic_2001.shp";
26 std::unique_ptr<te::da::DataSourceTransactor> transactor = ds_pols->getTransactor();
27 std::vector<std::string> datasets = transactor->getDataSetNames();
29 for(
unsigned int i=0; i<datasets.size(); ++i)
32 std::unique_ptr<te::da::DataSet> dataset = transactor->getDataSet(datasets[i]);
34 while(dataset->moveNext())
37 if((dataset->getString(
"nome")==
"Curitiba")||
38 (dataset->getString(
"nome")==
"Porto Alegre"))
40 std::cout <<
" Drawing city " << dataset->getString(
"nome") << std::endl;
44 std::unique_ptr<te::gm::Geometry> geometry = dataset->getGeometry(geomPos);
51 double factor = 0.0005;
53 double geot[6] = {zerox, factor, 0.0, ur.
y, 0.0, -factor};
56 std::string rname = dataset->getString(
"nome")+
".tif";
58 (
unsigned)(envelope->
getHeight()/factor + 1));
60 std::vector<te::rst::BandProperty*> bprops;
64 std::map<std::string, std::string> orinfo;
65 orinfo[
"URI"] = TERRALIB_DATA_DIR
"/geotiff/" + rname;
67 std::vector<te::gm::Geometry*> vgeometry;
68 vgeometry.push_back(geometry.get());
69 std::vector<double> colors;
70 colors.push_back(127.0);
76 std::cout <<
"Done!" << std::endl << std::endl;
78 catch(
const std::exception& e)
80 std::cout << std::endl <<
"An exception has occurred in RasterizePolygonSet(): " << e.what() << std::endl;
84 std::cout << std::endl <<
"An unexpected exception has occurred in RasterizePolygonSet()!" << std::endl;
void RasterizePolygonSet()
Test to open a shapefile and save some polygons in a raster file.
static std::unique_ptr< DataSource > make(const std::string &driver, const te::core::URI &connInfo)
A raster band description.
double getWidth() const
It returns the envelope width.
An utility struct for representing 2D coordinates.
void setGeoreference(const te::gm::Coord2D &ulLocation, int srid, double resX, double resY)
Sets the information needed to georeference the grid.
An Envelope defines a 2D rectangular region.
An abstract class for raster data strucutures.
virtual void rasterize(std::vector< te::gm::Geometry * > g, std::vector< double > vp, std::size_t b=0)
Rasterizes a given vector of geometries.
A factory for data sources.
These routines show how to use the raster module and the GDAL data source module. ...
static Raster * make()
It creates and returns an empty raster with default raster driver.
const double & getLowerLeftX() const
It returns a constant reference to the x coordinate of the lower left corner.
TEDATAACCESSEXPORT std::size_t GetFirstPropertyPos(const te::da::DataSet *dataset, int datatype)
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.
double getHeight() const
It returns the envelope height.
Utilitary functions to access GDAL and match some of its concepts to TerraLib concepts.