All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Raster.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/raster/Raster.cpp
22 
23  \brief An abstract class for raster data strucutures.
24 */
25 
26 // TerraLib
27 #include "../common/STLUtils.h"
28 #include "../geometry/Coord2D.h"
29 #include "../geometry/Envelope.h"
30 #include "../geometry/Polygon.h"
31 #include "../srs/Converter.h"
32 #include "Band.h"
33 #include "BandProperty.h"
34 #include "Exception.h"
35 #include "Grid.h"
36 #include "Interpolator.h"
37 #include "PositionIterator.h"
38 #include "Raster.h"
39 #include "RasterFactory.h"
40 #include "RasterProperty.h"
41 #include "Reprojection.h"
42 
43 // STL
44 #include <cassert>
45 #include <cmath>
46 #include <limits>
47 #include <memory>
48 
50  : m_grid(0),
51  m_policy(te::common::RAccess)
52 {
53 }
54 
56  : m_grid(grid),
57  m_policy(p)
58 {
59 }
60 
62  : m_name(rhs.m_name),
63  m_grid(0),
64  m_policy(rhs.m_policy)
65 {
66  m_grid = rhs.m_grid ? new Grid(*rhs.m_grid) : 0;
67 }
68 
70 {
71  delete m_grid;
72 }
73 
74 void te::rst::Raster::setName(const std::string name)
75 {
76  m_name = name;
77 }
78 
79 const std::string& te::rst::Raster::getName() const
80 {
81  return m_name;
82 }
83 
85 {
86  m_policy = p;
87 }
88 
90 {
91  return m_policy;
92 }
93 
95 {
96  return m_grid;
97 }
98 
100 {
101  return m_grid;
102 }
103 
105 {
106  return m_grid->getExtent();
107 }
108 
110 {
111  return m_grid->getExtent();
112 }
113 
115 {
116  if (srid==getSRID())
117  return new te::gm::Envelope(*getExtent());
118 
119  std::auto_ptr<te::srs::Converter> converter(new te::srs::Converter());
120  converter->setSourceSRID(getSRID());
121  converter->setTargetSRID(srid);
122 
123  unsigned int li=0, lf=getNumberOfRows()-1;
124  unsigned int ci=0, cf=getNumberOfColumns()-1;
125 
126  te::gm::Coord2D aux;
127  if (roi)
128  {
129  aux=m_grid->geoToGrid(roi->getLowerLeftX(),roi->getLowerLeftY());
130  li=static_cast<unsigned int>(aux.y);
131  ci=static_cast<unsigned int>(aux.x);
132 
133  aux=m_grid->geoToGrid(roi->getUpperRightX(),roi->getUpperRightY());
134  lf=static_cast<unsigned int>(aux.y);
135  cf=static_cast<unsigned int>(aux.x);
136  }
137 
138  aux=m_grid->gridToGeo(ci,lf);
139  converter->convert(aux.x,aux.y);
140  double llx=aux.x,
141  lly=aux.y;
142 
143  aux=m_grid->gridToGeo(cf,li);
144  converter->convert(aux.x,aux.y);
145  double urx=aux.x,
146  ury=aux.y;
147 
148  // follow the upper horizontal edge
149  for (unsigned int c=ci; c<cf; ++c)
150  {
151  aux=m_grid->gridToGeo(c,li);
152  if (converter->convert(aux.x,aux.y))
153  {
154  if(llx > aux.x) llx = aux.x;
155  if(lly > aux.y) lly = aux.y;
156  if(urx < aux.x) urx = aux.x;
157  if(ury < aux.y) ury = aux.y;
158  }
159  }
160 
161  // follow the lower horizontal edge
162  for (unsigned int c=ci; c<cf; ++c)
163  {
164  aux=m_grid->gridToGeo(c,lf);
165  if (converter->convert(aux.x,aux.y))
166  {
167  if(llx > aux.x) llx = aux.x;
168  if(lly > aux.y) lly = aux.y;
169  if(urx < aux.x) urx = aux.x;
170  if(ury < aux.y) ury = aux.y;
171  }
172  }
173 
174  // follow the left vertical edge
175  for (unsigned int l=li; l<lf; ++l)
176  {
177  aux=m_grid->gridToGeo(ci,l);
178  if (converter->convert(aux.x,aux.y))
179  {
180  if(llx > aux.x) llx = aux.x;
181  if(lly > aux.y) lly = aux.y;
182  if(urx < aux.x) urx = aux.x;
183  if(ury < aux.y) ury = aux.y;
184  }
185  }
186 
187  // follow the right vertical edge
188  for (unsigned int l=li; l<lf; ++l)
189  {
190  aux=m_grid->gridToGeo(cf,l);
191  if (converter->convert(aux.x,aux.y))
192  {
193  if(llx > aux.x) llx = aux.x;
194  if(lly > aux.y) lly = aux.y;
195  if(urx < aux.x) urx = aux.x;
196  if(ury < aux.y) ury = aux.y;
197  }
198  }
199 
200  return new te::gm::Envelope(llx,lly,urx,ury);
201 }
202 
204 {
205  return m_grid->getSRID();
206 }
207 
209 {
210  return m_grid->getNumberOfRows();
211 }
212 
214 {
215  return m_grid->getNumberOfColumns();
216 }
217 
219 {
220  return m_grid->getResolutionX();
221 }
222 
224 {
225  return m_grid->getResolutionY();
226 }
227 
228 void te::rst::Raster::getValue(unsigned int c, unsigned int r, double& value, std::size_t b) const
229 {
230  getBand(b)->getValue(c, r, value);
231 }
232 
233 void te::rst::Raster::setValue(unsigned int c, unsigned int r, const double value, std::size_t b)
234 {
235  getBand(b)->setValue(c, r, value);
236 }
237 
238 void te::rst::Raster::getIValue(unsigned int c, unsigned int r, double& value, std::size_t b) const
239 {
240  getBand(b)->getIValue(c, r, value);
241 }
242 
243 void te::rst::Raster::setIValue(unsigned int c, unsigned int r, const double value, std::size_t b)
244 {
245  getBand(b)->setIValue(c, r, value);
246 }
247 
248 void te::rst::Raster::getValue(unsigned int c, unsigned int r, std::complex<double>& value, std::size_t b) const
249 {
250  getBand(b)->getValue(c, r, value);
251 }
252 
253 void te::rst::Raster::setValue(unsigned int c, unsigned int r, const std::complex<double>& value, std::size_t b)
254 {
255  getBand(b)->setValue(c, r, value);
256 }
257 
258 void te::rst::Raster::getValues(unsigned int c, unsigned int r, std::vector<double>& values) const
259 {
260  values.clear();
261 
262  double v;
263 
264  for(std::size_t b = 0; b < getNumberOfBands(); b++)
265  {
266  getBand(b)->getValue(c, r, v);
267 
268  values.push_back(v);
269  }
270 }
271 
272 void te::rst::Raster::getValues(unsigned int c, unsigned int r, std::vector<std::complex<double> >& values) const
273 {
274  values.clear();
275 
276  std::complex<double> v;
277 
278  for(std::size_t b = 0; b < getNumberOfBands(); b++)
279  {
280  getBand(b)->getValue(c, r, v);
281 
282  values.push_back(v);
283  }
284 }
285 
286 void te::rst::Raster::setValues(unsigned int c, unsigned int r, const std::vector<double>& values)
287 {
288  assert(values.size() == getNumberOfBands());
289 
290  for(std::size_t b = 0; b < getNumberOfBands(); b++)
291  getBand(b)->setValue(c, r, values[b]);
292 }
293 
294 void te::rst::Raster::setValues(unsigned int c, unsigned int r, const std::vector<std::complex<double> >& values)
295 {
296  assert(values.size() == getNumberOfBands());
297 
298  for(std::size_t b = 0; b < getNumberOfBands(); b++)
299  getBand(b)->setValue(c, r, values[b]);
300 }
301 
302 std::string te::rst::Raster::toString(void) const
303 {
304  std::ostringstream output;
305 
306  output << std::endl;
307  output << "Raster Name......: " << m_name << std::endl;
308  output << "Number of Columns: " << getNumberOfColumns() << std::endl;
309  output << "Number of Rows...: " << getNumberOfRows() << std::endl;
310  output << "Number of Bands..: " << getNumberOfBands() << std::endl;
311  output << "SRID.............: " << getSRID() << std::endl;
312  output << "Resolution in X..: " << getResolutionX() << std::endl;
313  output << "Resolution in Y..: " << getResolutionY() << std::endl;
314  output << "Extent UR........: " << m_grid->getExtent()->getUpperRightX() << ", " << m_grid->getExtent()->getUpperRightY() << std::endl;
315  output << "Extent LL........: " << m_grid->getExtent()->getLowerLeftX() << ", " << m_grid->getExtent()->getLowerLeftY() << std::endl;
316 
317  for (std::size_t b = 0; b < getNumberOfBands(); b++)
318  {
319  output << std::endl;
320  output << "Band: " << b << " " << getBand(b)->getProperty()->m_description << std::endl;
321  output << " Min Values...: " << getBand(b)->getMinValue() << std::endl;
322  output << " Max Values...: " << getBand(b)->getMaxValue() << std::endl;
323  output << " Mean Values..: " << getBand(b)->getMeanValue() << std::endl;
324  output << " Std Values...: " << getBand(b)->getStdValue() << std::endl;
325  output << " Gain values..: " << getBand(b)->getScaleValue() << std::endl;
326  output << " Offset values: " << getBand(b)->getOffsetValue() << std::endl;
327  }
328 
329  output << std::endl;
330 
331  return output.str();
332 }
333 
335 {
336  assert(getNumberOfBands() == rhs.getNumberOfBands());
337 
338  for (std::size_t b = 0; b < getNumberOfBands(); b++)
339  this->operator[](b) += rhs.operator[](b);
340 
341  return *this;
342 }
343 
344 te::rst::Raster& te::rst::Raster::operator+=(std::complex<double>& cvalue)
345 {
346  for (std::size_t b = 0; b < getNumberOfBands(); b++)
347  this->operator[](b) += cvalue;
348 
349  return *this;
350 }
351 
353 {
354  assert(getNumberOfBands() == rhs.getNumberOfBands());
355 
356  for (std::size_t b = 0; b < getNumberOfBands(); b++)
357  this->operator[](b) -= rhs.operator[](b);
358 
359  return *this;
360 }
361 
362 te::rst::Raster& te::rst::Raster::operator-=(std::complex<double>& cvalue)
363 {
364  for (std::size_t b = 0; b < getNumberOfBands(); b++)
365  this->operator[](b) -= cvalue;
366 
367  return *this;
368 }
369 
371 {
372  assert(getNumberOfBands() == rhs.getNumberOfBands());
373 
374  for (std::size_t b = 0; b < getNumberOfBands(); b++)
375  this->operator[](b) *= rhs.operator[](b);
376 
377  return *this;
378 }
379 
380 te::rst::Raster& te::rst::Raster::operator*=(std::complex<double>& cvalue)
381 {
382  for (std::size_t b = 0; b < getNumberOfBands(); b++)
383  this->operator[](b) *= cvalue;
384 
385  return *this;
386 }
387 
389 {
390  assert(getNumberOfBands() == rhs.getNumberOfBands());
391 
392  for (std::size_t b = 0; b < getNumberOfBands(); b++)
393  this->operator[](b) /= rhs.operator[](b);
394 
395  return *this;
396 }
397 
398 te::rst::Raster& te::rst::Raster::operator/=(std::complex<double>& cvalue)
399 {
400  for (std::size_t b = 0; b < getNumberOfBands(); b++)
401  this->operator[](b) /= cvalue;
402 
403  return *this;
404 }
405 
407 {
408  assert(m_policy == te::common::RWAccess || m_policy == te::common::WAccess);
409 
410  if(this != &rhs)
411  {
412  m_name = rhs.m_name;
413 
414  delete m_grid;
415 
416  m_grid = rhs.m_grid ? new Grid(*rhs.m_grid) : 0;
417  }
418 
419  return *this;
420 }
421 
422 te::rst::Raster* te::rst::Raster::trim(const te::gm::Envelope* env, const std::map<std::string, std::string>& rinfo) const
423 {
424 // calculate output properties
425 
426  te::gm::Coord2D cllenv(m_grid->geoToGrid(env->getLowerLeftX(), env->getLowerLeftY()));
427  te::gm::Coord2D curenv(m_grid->geoToGrid(env->getUpperRightX(), env->getUpperRightY()));
428 
429  const unsigned int firstInputRow = (unsigned int)
430  std::min(
431  (double)( m_grid->getNumberOfRows() - 1 )
432  ,
433  std::max(
434  0.0
435  ,
436  std::floor( curenv.getY() )
437  )
438  );
439  const unsigned int firstInputCol = (unsigned int)
440  std::min(
441  (double)( m_grid->getNumberOfColumns() - 1 )
442  ,
443  std::max(
444  0.0
445  ,
446  std::floor( cllenv.getX() )
447  )
448  );
449  const unsigned int lastInputRow = (unsigned int)
450  std::min(
451  (double)( m_grid->getNumberOfRows() - 1 )
452  ,
453  std::max(
454  0.0
455  ,
456  std::ceil( cllenv.getY() )
457  )
458  );
459  const unsigned int lastInputCol = (unsigned int)
460  std::min(
461  (double)( m_grid->getNumberOfColumns() - 1 )
462  ,
463  std::max(
464  0.0
465  ,
466  std::ceil( curenv.getX() )
467  )
468  );
469 
470  if( ( lastInputRow <= firstInputRow ) || ( lastInputCol <= firstInputCol ) )
471  {
472  return 0;
473  }
474 
475  const unsigned int outputWidth = lastInputCol - firstInputCol + 1;
476  const unsigned int outputHeight = lastInputRow - firstInputRow + 1;
477 
478 // create output parameters and raster
479 
480  te::gm::Coord2D ulc( m_grid->gridToGeo( ((double)firstInputCol) - 0.5,
481  ((double)firstInputRow) - 0.5 ) );
482 
483  te::rst::Grid* grid = new te::rst::Grid( outputWidth, outputHeight, getResolutionX(),
484  getResolutionY(), &ulc, getSRID() );
485 
486  std::vector<te::rst::BandProperty*> bands;
487 
488  for (std::size_t b = 0; b < getNumberOfBands(); b++)
489  {
490  bands.push_back(new te::rst::BandProperty(*(getBand(b)->getProperty())));
491  bands[ b ]->m_nblocksx = 1;
492  bands[ b ]->m_nblocksy = outputHeight;
493  bands[ b ]->m_blkw = outputWidth;
494  bands[ b ]->m_blkh = 1;
495  }
496 
497  te::rst::Raster* rout = te::rst::RasterFactory::make(grid, bands, rinfo);
498 
499 // perform trim
500 
501  if( rout )
502  {
503  std::vector<std::complex<double> > values;
504  unsigned int ci = 0;
505  unsigned int ri = 0;
506  unsigned int co = 0;
507  unsigned int ro = 0;
508 
509  for( ri = firstInputRow, ro = 0; ro < outputHeight; ri++, ro++)
510  {
511  for( ci = firstInputCol, co = 0; co < outputWidth; ci++, co++)
512  {
513  getValues(ci, ri, values);
514 
515  rout->setValues(co, ro, values);
516  }
517  }
518  }
519 
520  return rout;
521 }
522 
523 te::rst::Raster* te::rst::Raster::resample(int method, int scale, const std::map<std::string, std::string>& rinfo) const
524 {
525  assert(scale != 0);
526 
527 // create output parameters and raster
528  te::rst::Grid* grid = new te::rst::Grid(*getResampledGrid(scale));
529 
530  std::vector<te::rst::BandProperty*> bands;
531 
532  for (std::size_t b = 0; b < getNumberOfBands(); b++)
533  bands.push_back(new te::rst::BandProperty(*(getBand(b)->getProperty())));
534 
535  te::rst::Raster* rout = te::rst::RasterFactory::make(grid, bands, rinfo);
536 
537 // define variables for interpolation
538  std::vector<std::complex<double> > v;
539 
540  double ripp = applyScale(scale, 1.0);
541 
542  double cipp = applyScale(scale, 1.0);
543 
544  double ri = 0.0;
545 
546  double ci;
547 
548  te::rst::Interpolator* interp = new te::rst::Interpolator(this, method);
549 
550 // fill output raster
551  for (unsigned r = 0; r < rout->getNumberOfRows(); r++, ri+=ripp)
552  {
553  ci = 0.0;
554  for (unsigned c = 0; c < rout->getNumberOfColumns(); c++, ci+=cipp)
555  {
556  interp->getValues(ci, ri, v);
557 
558  rout->setValues(c, r, v);
559  }
560  }
561 
562  return rout;
563 }
564 
565 te::rst::Raster* te::rst::Raster::resample(int method, unsigned int drow,
566  unsigned int dcolumn, unsigned int height, unsigned int width,
567  unsigned int newheight, unsigned int newwidth,
568  const std::map<std::string, std::string>& rinfo) const
569 {
570  assert(drow + height <= getNumberOfRows());
571  assert(dcolumn + width <= getNumberOfColumns());
572 
573  te::gm::Coord2D ulc = getGrid()->gridToGeo( ((double)dcolumn) - 0.5, ((double)drow) - 0.5);
574  te::gm::Coord2D lrc = getGrid()->gridToGeo( ((double)(dcolumn + width)) - 0.5,
575  ((double)(drow + height)) - 0.5);
576 
577  te::gm::Envelope* newEnvelopePtr = new te::gm::Envelope( ulc.x, lrc.y, lrc.x,
578  ulc.y );
579 
580  // create output parameters and raster
581 
582  te::rst::Grid* grid = new te::rst::Grid(newwidth, newheight, newEnvelopePtr,
583  getSRID());
584 
585  std::vector<te::rst::BandProperty*> bands;
586 
587  for (std::size_t b = 0; b < getNumberOfBands(); b++)
588  {
589  bands.push_back(new te::rst::BandProperty(*(getBand(b)->getProperty())));
590  bands[ b ]->m_blkh = 1;
591  bands[ b ]->m_blkw = newwidth;
592  bands[ b ]->m_nblocksx = 1;
593  bands[ b ]->m_nblocksy = newheight;
594  }
595 
596  te::rst::Raster* rout = te::rst::RasterFactory::make(grid, bands, rinfo);
597 
598 // define variables for interpolation
599  std::vector<std::complex<double> > v;
600 
601  te::rst::Interpolator* interp = new te::rst::Interpolator(this, method);
602 
603 // fill output raster
604  double ripp = ((double)(height-1)) / ((double)(newheight-1));
605 
606  double cipp = ((double)(width-1)) / ((double)(newwidth-1));
607 
608  double ri = drow;
609 
610  double ci;
611 
612  for (unsigned r = 0; r < newheight; r++, ri+=ripp)
613  {
614  ci = dcolumn;
615  for (unsigned c = 0; c < newwidth; c++, ci+=cipp)
616  {
617  interp->getValues(ci, ri, v);
618 
619  rout->setValues(c, r, v);
620  }
621  }
622 
623  return rout;
624 }
625 
627 {
628  assert(scale != 0);
629 
630  te::gm::Coord2D* ulc = new te::gm::Coord2D(getExtent()->getLowerLeftX(), getExtent()->getUpperRightY());
631 
632  return new te::rst::Grid((unsigned) std::ceil(applyScale(-scale, getNumberOfColumns())),
633  (unsigned) std::ceil(applyScale(-scale, getNumberOfRows())),
634  applyScale(scale, getResolutionX()), applyScale(scale, getResolutionY()),
635  ulc, getSRID());
636 }
637 
638 double te::rst::Raster::applyScale(int i, const double& v) const
639 {
640  if (i > 0)
641  return (v / i);
642 
643  return (v * -i);
644 }
645 
646 te::rst::Raster* te::rst::Raster::transform(int srid, const std::map<std::string, std::string>& rinfo, int m) const
647 {
648  te::gm::Envelope transformedEnvelope( *getExtent() );
649  transformedEnvelope.transform( getSRID(), srid );
650 
651  double transformedResolutionX = transformedEnvelope.getWidth() /
652  ((double)getNumberOfColumns());
653  double transformedResolutionY = transformedEnvelope.getHeight() /
654  ((double)getNumberOfRows());
655 
656  return te::rst::Reproject(
657  this,
658  srid,
659  getExtent()->getLowerLeftX(),
660  getExtent()->getLowerLeftY(),
661  getExtent()->getUpperRightX(),
662  getExtent()->getUpperRightY(),
663  transformedResolutionX,
664  transformedResolutionY,
665  rinfo,
666  m);
667 }
668 
669 te::rst::Raster* te::rst::Raster::transform(int srid, double llx, double lly, double urx, double ury, const std::map<std::string, std::string>& rinfo, int m) const
670 {
671  return this->transform(srid, llx, lly, urx, ury, 0, 0, rinfo, m);
672 }
673 
674 te::rst::Raster* te::rst::Raster::transform(int srid, double llx, double lly, double urx, double ury, double resx, double resy, const std::map<std::string, std::string>& rinfo, int m) const
675 {
676  return te::rst::Reproject(this, srid, llx, lly, urx, ury, resx, resy, rinfo, m);
677 }
678 
679 void te::rst::Raster::vectorize(std::vector<te::gm::Geometry*>& g, std::size_t b, unsigned int mp)
680 {
681  g.clear();
682 
683  te::rst::Vectorizer vectorizer(this, b, mp);
684 
685  vectorizer.run(g);
686 }
687 
688 void te::rst::Raster::rasterize(std::vector<te::gm::Geometry*> g, std::vector<double> vp, std::size_t b)
689 {
690  assert(b < getNumberOfBands());
691 
692  te::rst::Band* band = getBand(b);
693 
694 // if vp is empty, create a vector of contrastand pixel values for neighboring polygons
695  if (vp.size() == 0)
696  {
697  int bvalue = 254;
698  for (unsigned int i = 0; i < g.size(); i++)
699  {
700  vp.push_back(bvalue % 255);
701 
702  bvalue = bvalue >= 127? bvalue - 126: bvalue > 255? 0: bvalue + 127;
703  }
704  }
705 
706  for (unsigned int i = 0; i < g.size(); i++)
707  {
708  te::gm::Polygon* polygon = static_cast<te::gm::Polygon*> (g[i]);
709 
712 
713  while (it != itend)
714  {
715  setValue(it.getColumn(), it.getRow(), vp[i], b);
716 
717  ++it;
718  }
719  }
720 }
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.
Definition: Raster.cpp:233
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.
Definition: Raster.cpp:286
te::gm::Envelope * getExtent()
Returns the geographic extension of the raster data.
Definition: Raster.cpp:104
void getValues(const double &c, const double &r, std::vector< std::complex< double > > &values)
Get the interpolated value for all bands.
double y
y-coordinate.
Definition: Coord2D.h:114
It describes one band (or dimension) of a raster.
It contains the algorithm to reproject raster data.
double applyScale(int i, const double &v) const
Scales a value according to a specific resampling scale.
Definition: Raster.cpp:638
A raster band description.
Definition: BandProperty.h:61
double x
x-coordinate.
Definition: Coord2D.h:113
virtual Raster & operator/=(Raster &rhs)
It returns the raster division (pixel by pixel).
Definition: Raster.cpp:388
Raster property.
unsigned int getNumberOfColumns() const
Returns the raster number of columns.
Definition: Raster.cpp:213
It interpolates one pixel based on a selected algorithm. Methods currently available are Nearest Neig...
Definition: Interpolator.h:55
virtual Raster * trim(const te::gm::Envelope *env, const std::map< std::string, std::string > &rinfo) const
Subsetting operation for trimming (cropping) the raster.
Definition: Raster.cpp:422
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.
Definition: Raster.cpp:258
const double & getUpperRightX() const
It returns a constant refernce to the x coordinate of the upper right corner.
Definition: Envelope.h:410
This class implements the strategy to iterate with spatial restriction, the iteration occurs inside a...
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.
Definition: Raster.cpp:565
const double & getLowerLeftY() const
It returns a constant refernce to the y coordinate of the lower left corner.
Definition: Envelope.h:400
double getWidth() const
It returns the envelope width.
Definition: Envelope.h:443
virtual void setIValue(unsigned int c, unsigned int r, const double value, std::size_t b=0)
Sets the imaginary attribute value in a complex band of a cell.
Definition: Raster.cpp:243
unsigned int getRow() const
Returns the current row in iterator.
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
double getY() const
It returns the y-coordinate.
Definition: Coord2D.h:108
virtual Raster & operator*=(Raster &rhs)
It returns the raster product (pixel by pixel).
Definition: Raster.cpp:370
const double & getUpperRightY() const
It returns a constant refernce to the x coordinate of the upper right corner.
Definition: Envelope.h:420
void setAccessPolicy(te::common::AccessPolicy p)
Sets the raster access policy.
Definition: Raster.cpp:84
te::common::AccessPolicy getAccessPolicy() const
Returns the raster access policy.
Definition: Raster.cpp:89
std::string m_name
The raster name.
Definition: Raster.h:680
Grid * m_grid
The spatial support for raster data.
Definition: Raster.h:681
Grid * getResampledGrid(int scale) const
Return the raster grid for a specific scale.
Definition: Raster.cpp:626
AccessPolicy
Supported data access policies (can be used as bitfield).
Definition: Enums.h:40
An exception class for the Raster module.
Raster()
Default constructor.
Definition: Raster.cpp:49
bool run(std::vector< te::gm::Geometry * > &polygons)
Returns true if current algorithm implementation runs ok, false otherwise.
Definition: Vectorizer.cpp:159
static PolygonIterator end(const te::rst::Raster *r, const te::gm::Polygon *p)
Returns an iterator referring to after the end of the iterator.
An abstract class for raster data strucutures.
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
An abstract class for raster data strucutures.
Definition: Raster.h:71
unsigned int getNumberOfRows() const
Returns the raster number of rows.
Definition: Raster.cpp:208
virtual ~Raster()
Virtual destructor.
Definition: Raster.cpp:69
virtual void rasterize(std::vector< te::gm::Geometry * > g, std::vector< double > vp, std::size_t b=0)
Rasterizes a given vector of geometries.
Definition: Raster.cpp:688
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
virtual Raster & operator-=(Raster &rhs)
It returns the raster subtraction (pixel by pixel).
Definition: Raster.cpp:352
virtual Raster * getRaster() const =0
Returns the associated raster.
double getResolutionX() const
Returns the raster horizontal (x-axis) resolution.
Definition: Raster.cpp:218
void setName(const std::string name)
Sets the raster name.
Definition: Raster.cpp:74
It implements the vectorizer, based on TerraLib 4 algorithm.
Definition: Vectorizer.h:72
It gives access to values in one band (dimension) of a raster.
A raster band description.
Definition: Band.h:63
Grid * getGrid()
It returns the raster grid.
Definition: Raster.cpp:94
virtual Raster & operator=(const Raster &rhs)
Assignment operator.
Definition: Raster.cpp:406
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.
Definition: Raster.cpp:228
A Converter is responsible for the conversion of coordinates between different Coordinate Systems (CS...
Definition: Converter.h:53
std::string toString(void) const
It returns the data value in a string notation.
Definition: Raster.cpp:302
int getSRID() const
Returns the raster spatial reference system identifier.
Definition: Raster.cpp:203
const std::string & getName() const
Returns the raster name.
Definition: Raster.cpp:79
virtual Raster * transform(int srid, const std::map< std::string, std::string > &rinfo, int m=1) const
Reprojects this raster to a distinct SRS. This method reprojects this raster to a distinct SRS...
Definition: Raster.cpp:646
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:50
double getX() const
It returns the x-coordinate.
Definition: Coord2D.h:102
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.
static PolygonIterator begin(const te::rst::Raster *r, const te::gm::Polygon *p)
Returns an iterator referring to the first value of the band.
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.
Definition: Envelope.h:390
A rectified grid is the spatial support for raster data.
double getResolutionY() const
Returns the raster vertical (y-axis) resolution.
Definition: Raster.cpp:223
virtual void getIValue(unsigned int c, unsigned int r, double &value, std::size_t b=0) const
Returns the imaginary attribute value in a complex band of a cell.
Definition: Raster.cpp:238
This is the abstract factory for Rasters.
unsigned int getColumn() const
Returns the current column in iterator.
A rectified grid is the spatial support for raster data.
Definition: Grid.h:68
void transform(int oldsrid, int newsrid)
It will transform the coordinates of the Envelope from the old SRS to the new one.
Definition: Envelope.cpp:92
double getHeight() const
It returns the envelope height.
Definition: Envelope.h:448
virtual Raster & operator+=(Raster &rhs)
It returns the raster sum (pixel by pixel).
Definition: Raster.cpp:334
It interpolates one pixel based on a selected algorithm.
virtual void vectorize(std::vector< te::gm::Geometry * > &g, std::size_t b, unsigned int mp=0)
Vectorizes a given raster band, using GDALPolygonize function.
Definition: Raster.cpp:679