7 #if TE_EXAMPLE_USE_GRIB 8 #include <terralib/grib/Raster.h> 9 #include <terralib/grib/Band.h> 10 #endif // TE_EXAMPLE_USE_GRIB 27 s->
setPoint(4, llx + (urx - llx) / 2.0 , lly + (ury - lly) / 2.0);
51 int ri = (
int) cccci.
y;
52 int rf = (
int) ccccf.
y;
54 int ci = (
int) cccci.
x;
55 int cf = (
int) ccccf.
x;
57 double areaPixel = resx * resy;
61 for(
int r = ri; r <= rf; ++r)
64 double ury = lly + resy;
65 for(
int c = ci; c <= cf; ++c)
69 double urx = llx + resx;
71 std::unique_ptr<te::gm::Polygon> pixelPoly(
createPolygon(llx, lly, urx, ury));
73 if (pixelPoly->within(poly))
74 areaInside = areaPixel;
77 std::unique_ptr<te::gm::Geometry> inter(pixelPoly->intersection(poly));
89 value = areaInside / areaPixel;
98 const std::map<std::string, std::string>& routinfo = std::map<std::string, std::string>(),
103 std::vector<te::rst::BandProperty*> bp;
111 for (
unsigned r = 0; r < oraster->getNumberOfRows(); ++r)
112 for (
unsigned c = 0; c < oraster->getNumberOfColumns(); ++c)
113 oraster->setValue(c, r, 0.0);
115 Mask(iraster, poly, oraster.get());
117 return oraster.release();
124 std::cout <<
"This test uses Grib and Geometry." << std::endl << std::endl;
146 std::map<std::string, std::string> routinfo;
148 routinfo[
"URI"] = TERRALIB_DATA_DIR
"/geotiff/Z500_out.tif";
150 std::unique_ptr<te::rst::Raster> newRaster(
Mask(iraster.get(), poly.get(), routinfo));
152 std::cout <<
"Done!" << std::endl << std::endl;
154 catch(
const std::exception& e)
156 std::cout << std::endl <<
"An exception has occurred in GribPolygonExample(): " << e.what() << std::endl;
160 std::cout << std::endl <<
"An unexpected exception has occurred in GribPolygonExample()!" << std::endl;
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.
void push_back(Curve *ring)
It adds the curve to the curve polygon.
void GribPolygonExample()
An example to use Grib and Geometry.
#define TE_DEFAULT_RASTER_TYPE
A raster band description.
const double & getUpperRightX() const
It returns a constant refernce to the x coordinate of the upper right corner.
const double & getLowerLeftY() const
It returns a constant refernce to the y coordinate of the lower left corner.
An utility struct for representing 2D coordinates.
const double & getUpperRightY() const
It returns a constant refernce to the x coordinate of the upper right corner.
void geoToGrid(const double &x, const double &y, double &col, double &row) const
Get the grid point associated to a spatial location.
A LinearRing is a LineString that is both closed and simple.
const Envelope * getMBR() const _NOEXCEPT_OP(true)
It returns the minimum bounding rectangle for the geometry in an internal representation.
void setPoint(std::size_t i, const double &x, const double &y)
It sets the value of the specified point.
An Envelope defines a 2D rectangular region.
An abstract class for raster data strucutures.
double getResolutionX() const
Returns the raster horizontal (x-axis) resolution.
Grid * getGrid()
It returns the raster grid.
double getArea() const
It returns the area of this surface, as measured in the spatial reference system of this surface...
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
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.
te::gm::Envelope * getExtent()
Returns the geographic extension of the grid.
double getResolutionY() const
Returns the raster vertical (y-axis) resolution.
void Mask(te::rst::Raster *iraster, const te::gm::Polygon *poly, te::rst::Raster *oraster)
This file contains include headers for the Vector Geometry model of TerraLib.
A rectified grid is the spatial support for raster data.
te::gm::Polygon * createPolygon(const double &llx, const double &lly, const double &urx, const double &ury)
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.