Loading...
Searching...
No Matches
Raster.h
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.h
22
23 \brief An abstract class for raster data strucutures.
24*/
25
26#ifndef __TERRALIB_RASTER_INTERNAL_RASTER_H
27#define __TERRALIB_RASTER_INTERNAL_RASTER_H
28
29// TerraLib
30#include "../common/Enums.h"
31#include "../datatype/AbstractData.h"
32#include "../datatype/Enums.h"
33#include "../geometry/Geometry.h"
34#include "Config.h"
35#include "Vectorizer.h"
36
37// STL
38#include <complex>
39#include <map>
40#include <string>
41#include <vector>
42
43// Boost
44#include <boost/shared_ptr.hpp>
45
46namespace te
47{
48// Forward declaration
49 namespace gm { class Envelope; }
50
51 namespace rst
52 {
53// Forward declaration
54 class Band;
55 class BandProperty;
56 class Grid;
57
58 /*!
59 \class Raster
60
61 \brief An abstract class for raster data strucutures.
62
63 A raster data structure represents a geograhical area divided into rows and columns,
64 which form a regular grid structure of cells. Each cell contains location co-ordinates and
65 one or more attribute values.
66
67 This interface should be implemented by drivers that provide the real access to raster data.
68
69 \ingroup rst
70 */
72 {
73 public:
74
75 /*! \brief Default constructor. */
77
78 /*!
79 \brief Constructor to create a raster from parameters.
80
81 \param grid The grid definition. The Raster will take its ownership.
82 \param p Access Policy.
83 */
85
86 /*!
87 \brief Copy constructor.
88
89 \param rhs The right-hand side Raster.
90 */
91 Raster(const Raster& rhs);
92
93 /*! \brief Virtual destructor. */
94 virtual ~Raster();
95
96 /*!
97 \brief Opens a raster.
98
99 \param rinfo The information needed by each driver to open the raster.
100 \param p Access Policy.
101 */
102 virtual void open(const std::map<std::string, std::string>& rinfo, te::common::AccessPolicy p = te::common::RAccess) = 0;
103
104 /*!
105 \brief Sets the raster name.
106
107 \param name The new raster name.
108 */
109 void setName(const std::string name);
110
111 /*! \brief Returns the raster name. */
112 const std::string& getName() const;
113
114 /*!
115 \brief Sets the raster access policy.
116
117 \param p The new raster access policy.
118 */
120
121 /*! \brief Returns the raster access policy. */
123
124 /*!
125 \brief It returns additional information about the raster.
126
127 The return of thi smethod is driver dependent.
128
129 \return Additional information about the raster.
130 */
131 virtual std::map<std::string, std::string> getInfo() const = 0;
132
133 /*! \brief It returns the raster grid. */
135
136 /*! \brief It returns the raster grid. */
137 const Grid* getGrid() const;
138
139 /*! \brief Returns the geographic extension of the raster data. */
141
142 /*! \brief Returns the geographic extension of the raster data. */
144
145 /*!
146 \brief Returns the geographic extension of the raster data, in a given SRS (distinct from its original one).
147
148 \param srid The target SRS id.
149 \param roi Pointer to a region of interest. If NULL the original extenstion will be considered.
150
151 \return A pointer the raster extension in a given SRS or NULL if it fails.
152
153 \note The caller will take the ownership of the returned pointer.
154 */
155 te::gm::Envelope* getExtent(int srid, te::gm::Envelope* roi = 0) const;
156
157 /*! \brief Returns the raster spatial reference system identifier. */
158 int getSRID() const;
159
160 /*! \brief Returns the raster number of rows. */
161 unsigned int getNumberOfRows() const;
162
163 /*! \brief Returns the raster number of columns. */
164 unsigned int getNumberOfColumns() const;
165
166 /*! \brief Returns the raster horizontal (x-axis) resolution. */
167 double getResolutionX() const;
168
169 /*! \brief Returns the raster vertical (y-axis) resolution. */
170 double getResolutionY() const;
171
172 /*! \brief Returns the number of bands (dimension of cells attribute values) in the raster. */
173 virtual std::size_t getNumberOfBands() const = 0;
174
175 /*!
176 \brief Returns the data type in a particular band (or dimension).
177
178 \note The data types are listed in terralib/datatype/DataTypes.h
179
180 \param i The desired band.
181
182 \return The data type in a particular band (or dimension).
183 */
184 virtual int getBandDataType(std::size_t i) const = 0;
185
186 /*!
187 \brief Returns the raster i-th band.
188
189 \param i The band index.
190
191 \warning The caller is reponsible for providing a valid band index.
192 */
193 virtual const Band* getBand(std::size_t i) const = 0;
194
195 /*!
196 \brief Returns the raster i-th band.
197
198 \param i The band index.
199
200 \warning The caller is reponsible for providing a valid band index.
201 */
202 virtual Band* getBand(std::size_t i) = 0;
203
204 /*!
205 \brief Access band in i position.
206
207 \param i The band index.
208
209 \warning The caller is reponsible for providing a valid band index.
210
211 \return A reference to the i-th band.
212 */
213 virtual const Band& operator[](std::size_t i) const = 0;
214
215 /*!
216 \brief Access band in i position.
217
218 \param i The band index.
219
220 \warning The caller is reponsible for providing a valid band index.
221
222 \return A reference to the i-th band.
223 */
224 virtual Band& operator[](std::size_t i) = 0;
225
226 /*!
227 \brief Returns the attribute value of a band of a cell.
228
229 \param c The column location of the cell.
230 \param r The row location of the cell.
231 \param value To return the attribute value.
232 \param b A particular band of the cell attribute.
233
234 \warning The caller is responsible for providing correct values for the range [c x r x b].
235
236 \exception Exception Subclasses may throw an exception if the data value can not be read.
237 */
238 virtual void getValue(unsigned int c, unsigned int r, double& value, std::size_t b = 0) const;
239
240 /*!
241 \brief Sets the attribute value in a band of a cell.
242
243 \param c The column location of the cell.
244 \param r The row location of the cell.
245 \param value The attribute value to be assigned.
246 \param b A particular band of the cell attribute.
247
248 \warning The caller is responsible for providing correct values for the range [c x r x b].
249
250 \exception Exception Subclasses may throw an exception if the data value can not be write.
251 */
252 virtual void setValue(unsigned int c, unsigned int r, const double value, std::size_t b = 0);
253
254 /*!
255 \brief Returns the imaginary attribute value in a complex band of a cell.
256
257 \param c The column location of the cell.
258 \param r The row location of the cell.
259 \param value The attribute value to be assigned.
260 \param b A particular band of the cell attribute. Default value 0.
261
262 \warning The caller is responsible for providing correct values for the range [c x r x b].
263
264 \exception Exception Subclasses may throw an exception if the data value can not be read.
265 */
266 virtual void getIValue(unsigned int c, unsigned int r, double& value, std::size_t b = 0) const;
267
268 /*!
269 \brief Sets the imaginary attribute value in a complex band of a cell.
270
271 \param c The column location of the cell.
272 \param r The row location of the cell.
273 \param value The attribute value to be assigned.
274 \param b A particular band of the cell attribute. Default value 0.
275
276 \warning The caller is responsible for providing correct values for the range [c x r x b].
277
278 \exception Exception Subclasses may throw an exception if the data value can not be write.
279 */
280 virtual void setIValue(unsigned int c, unsigned int r, const double value, std::size_t b = 0);
281
282 /*!
283 \brief Returns the imaginary attribute value in a complex band of a cell.
284
285 \param c The column location of the cell.
286 \param r The row location of the cell.
287 \param value The complex attribute value to be assigned (real, imaginary).
288 \param b A particular band of the cell attribute. Default value 0.
289
290 \warning The caller is responsible for providing correct values for the range [c x r x b].
291
292 \exception Exception Subclasses may throw an exception if the data value can not be read.
293 */
294 virtual void getValue(unsigned int c, unsigned int r, std::complex<double>& value, std::size_t b = 0) const;
295
296 /*!
297 \brief Sets the imaginary attribute value in a complex band of a cell.
298
299 \param c The column location of the cell.
300 \param r The row location of the cell.
301 \param value The complex attribute value to be assigned (real, imaginary).
302 \param b A particular band of the cell attribute. Default value 0.
303
304 \warning The caller is responsible for providing correct values for the range [c x r x b].
305
306 \exception Exception Subclasses may throw an exception if the data value can not be write.
307 */
308 virtual void setValue(unsigned int c, unsigned int r, const std::complex<double>& value, std::size_t b = 0);
309
310 /*!
311 \brief Returns the imaginary attribute values in all complex bands of a cell.
312
313 \param c The column location of the cell.
314 \param r The row location of the cell.
315 \param values A vector of attribute values to be assigned (not complex values).
316
317 \warning The caller is responsible for providing correct values for the range [c x r].
318
319 \exception Exception Subclasses may throw an exception if the data value can not be read.
320 */
321 virtual void getValues(unsigned int c, unsigned int r, std::vector<double>& values) const;
322
323 /*!
324 \brief Returns the imaginary attribute values in all complex bands of a cell.
325
326 \param c The column location of the cell.
327 \param r The row location of the cell.
328 \param values A vector of complex attribute values to be assigned (real, imaginary).
329
330 \warning The caller is responsible for providing correct values for the range [c x r].
331
332 \exception Exception Subclasses may throw an exception if the data value can not be read.
333 */
334 virtual void getValues(unsigned int c, unsigned int r, std::vector<std::complex<double> >& values) const;
335
336 /*!
337 \brief Sets the imaginary attribute values in all complex bands of a cell.
338
339 \param c The column location of the cell.
340 \param r The row location of the cell.
341 \param values A vector of attribute values to be assigned (not complex values).
342
343 \warning The caller is responsible for providing correct values for the range [c x r].
344
345 \exception Exception Subclasses may throw an exception if the data value can not be write.
346 */
347 virtual void setValues(unsigned int c, unsigned int r, const std::vector<double>& values);
348
349 /*!
350 \brief Sets the imaginary attribute values in all complex bands of a cell.
351
352 \param c The column location of the cell.
353 \param r The row location of the cell.
354 \param values A vector of complex attribute values to be assigned (real, imaginary).
355
356 \warning The caller is responsible for providing correct values for the range [c x r].
357
358 \exception Exception Subclasses may throw an exception if the data value can not be write.
359 */
360 virtual void setValues(unsigned int c, unsigned int r, const std::vector<std::complex<double> >& values);
361
362 int getTypeCode() const { return te::dt::RASTER_TYPE; }
363
364 std::string toString(void) const;
365
366 /*!
367 \brief It calls a parameter function f to apply in all pixels from two rasters, e.g. pixel = f(lhs, rhs);
368
369 \param (*f) a function with the signature complex<double>(*f)(complex<double>, complex<double>), const Raster& rhs)
370
371 \param rhs The rhs raster to apply the function.
372
373 \return The resultant raster.
374 */
375 Raster& callOperator(std::complex<double>(*f)(std::complex<double>, std::complex<double>), const Raster& rhs);
376
377 /*!
378 \brief It returns the raster sum (pixel by pixel).
379
380 \param rhs The raster to be added, right-hand side.
381
382 \note Both rasters must have the same properties, #bands, #columns,
383 #rows, and data type.
384
385 \note The caller is responsible to guarantee that resultant values
386 will not exceed the range of the data type.
387
388 \return The raster sum.
389 */
390 virtual Raster& operator+=(Raster& rhs);
391
392 /*!
393 \brief It returns the sum of a constant value to all pixels in the raster.
394
395 \param cvalue The constant value to be added.
396
397 \note The caller is responsible to guarantee that resultant values
398 will not exceed the range of the data type.
399
400 \return The raster sum.
401 */
402 virtual Raster& operator+=(std::complex<double>& cvalue);
403
404 /*!
405 \brief It returns the raster subtraction (pixel by pixel).
406
407 \param rhs The raster to be subtracted, right-hand side.
408
409 \note Both rasters must have the same properties, #bands, #columns,
410 #rows, and data type.
411
412 \note The caller is responsible to guarantee that resultant values
413 will not exceed the range of the data type.
414
415 \return The raster subtraction.
416 */
417 virtual Raster& operator-=(Raster& rhs);
418
419 /*!
420 \brief It returns the difference from all pixels in the raster to a constant value (pixels - constant).
421
422 \param cvalue The constant value to be subtracted.
423
424 \note The caller is responsible to guarantee that resultant values
425 will not exceed the range of the data type.
426
427 \return The raster difference.
428 */
429 virtual Raster& operator-=(std::complex<double>& cvalue);
430
431 /*!
432 \brief It returns the raster product (pixel by pixel).
433
434 \param rhs The raster to be multiplied, right-hand side.
435
436 \note Both rasters must have the same properties, #bands, #columns,
437 #rows, and data type.
438
439 \note The caller is responsible to guarantee that resultant values
440 will not exceed the range of the data type.
441
442 \return The raster product.
443 */
444 virtual Raster& operator*=(Raster& rhs);
445
446 /*!
447 \brief It returns the product of a constant value to all pixels in the raster.
448
449 \param cvalue The constant value to be multiplied.
450
451 \note The caller is responsible to guarantee that resultant values
452 will not exceed the range of the data type.
453
454 \return The raster product.
455 */
456 virtual Raster& operator*=(std::complex<double>& cvalue);
457
458 /*!
459 \brief It returns the raster division (pixel by pixel).
460
461 \param rhs The raster to be divided, right-hand side.
462
463 \note Both rasters must have the same properties, #bands, #columns,
464 #rows, and data type.
465
466 \note The caller is responsible to guarantee that resultant values
467 will not exceed the range of the data type.
468
469 \return The raster division.
470 */
471 virtual Raster& operator/=(Raster& rhs);
472
473 /*!
474 \brief It returns the division of all pixels in the raster by a constant value (pixels / constant).
475
476 \param cvalue The constant value to be divided.
477
478 \note The caller is responsible to guarantee that resultant values
479 will not exceed the range of the data type.
480
481 \return The raster division.
482 */
483 virtual Raster& operator/=(std::complex<double>& cvalue);
484
485 /*!
486 \brief Assignment operator.
487
488 \param rhs The right-hand-side copy that would be used to copy from.
489
490 \return A reference to this object.
491 */
492 virtual Raster& operator=(const Raster& rhs);
493
494 /*!
495 \brief Subsetting operation for trimming (cropping) the raster.
496
497 \param env The envelope (inside original extent) to crop the raster.
498 \param rinfo The parameters needed to build the output raster (see RasterFactory documentation).
499
500 \return A pointer to the trimmed raster if success and a null pointer otherwise.
501
502 \note The caller will take the ownership of the returned pointer.
503 */
504 virtual Raster* trim(const te::gm::Envelope* env, const std::map<std::string, std::string>& rinfo) const;
505
506 /*!
507 \brief Subsetting operation for trimming (cropping) the raster.
508
509 \param env The envelope (inside original extent) to crop the raster.
510 \param rinfo The parameters needed to build the output raster (see RasterFactory documentation).
511 \param rType The name of the specific driver to create the raster.
512
513 \return A pointer to the trimmed raster if success and a null pointer otherwise.
514
515 \note The caller will take the ownership of the returned pointer.
516 */
517 virtual Raster* trim(const te::gm::Envelope* env, const std::map<std::string, std::string>& rinfo, const std::string& rType) const;
518
519 /*!
520 \brief Subsetting operation for clipping the raster.
521
522 \param geometries A vector of pointers to valid geometries.
523 \param rinfo The parameters needed to build the output raster (see RasterFactory documentation).
524 \param rType The name of the specific driver to create the raster.
525
526 \return A pointer to the trimmed raster if success and a null pointer otherwise.
527
528 \note The caller will take the ownership of the returned pointer.
529 \note Accepted geometry types: te::gm::Polygon, te::gm::MultiPolygon
530 */
531 virtual Raster* clip(const std::vector< te::gm::Geometry const *> geometries,
532 const std::map<std::string, std::string>& rinfo,
533 const std::string& rType ) const;
534
535 /*!
536 \brief Resample a subset of the raster, given a box.
537
538 \param method The method of interpolation. \sa te::rst::Interpolator
539 \param drow The starting row to make a subset of the image.
540 \param dcolumn The starting column to make a subset of the image.
541 \param height The height of the subset.
542 \param width The width of the subset.
543 \param newheight The resampled height of the new raster.
544 \param newwidth The resampled width of the new raster.
545 \param rinfo The parameters needed to build the output raster (see RasterFactory documentation).
546
547 \return A pointer to the resampled raster if success and a null pointer otherwise.
548
549 \note The caller will take the ownership of the returned pointer.
550
551 \warning A scale of 0 is not allowed. Use 1, 2, 3, or -1, -2, 3...
552 */
553 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;
554
555 /*!
556 \brief Resample raster.
557
558 \param method The method of interpolation.
559 \param scale The scale of interpolation (use - to shrink or + to enlarge).
560 \param rinfo The parameters needed to build the output raster (see RasterFactory documentation).
561
562 \return A pointer to the resampled raster if success and a null pointer otherwise.
563
564 \note The caller will take the ownership of the returned pointer.
565
566 \warning A scale of 0 is not allowed. Use 1, 2, 3, or -1, -2, 3...
567 */
568 virtual Raster* resample(int method, int scale, const std::map<std::string, std::string>& rinfo) const;
569
570 /*!
571 \brief Return the raster grid for a specific scale.
572
573 \param scale The desired sacale of interpolation (use - to shrink or + to enlarge).
574
575 \return The raster grid.
576
577 \note The caller will take the ownership of the returned pointer.
578 */
579 Grid* getResampledGrid(int scale) const;
580
581 /*!
582 \brief Reprojects this raster to a distinct SRS.
583 This method reprojects this raster to a distinct SRS. The output resolution
584 is calculated in order to maintain the same number of pixels as in this raster.
585
586 \param srid The target SRS identifier.
587 \param rinfo The parameters needed to build the output raster (see RasterFactory documentation).
588 \param m The method of interpolation to apply (default 1 = nearest neighbor). \sa te::rst::Interpolator
589
590
591 \return A pointer to the reprojected raster if success and a null pointer otherwise.
592
593 \note The caller will take the ownership of the returned pointer.
594 */
595 virtual Raster* transform(int srid, const std::map<std::string, std::string>& rinfo, int m = 1) const;
596
597 /*!
598 \brief Reprojects a squared portion of this raster to a distinct SRS.
599 This method reprojects a squared portion of this raster to a distinct SRS.
600 The output resolution is calculated in order to maintain the same number
601 of pixels as in the desired portion of this raster.
602
603 \param srid The target SRS identifier.
604 \param llx Lower-left X-coordinate of the portion to be reprojected (in the original SRS).
605 \param lly Lower-left Y-coordinate of the portion to be reprojected (in the original SRS).
606 \param urx Upper-Right X-coordinate of the portion to be reprojected (in the original SRS).
607 \param url Upper-Right Y-coordinate of the portion to be reprojected (in the original SRS).
608 \param rinfo The parameters needed to build the output raster (see RasterFactory documentation).
609 \param m The method of interpolation to apply (default 1 = nearest neighbor). \sa te::rst::Interpolator
610
611 \return A pointer to the reprojected raster if success and a null pointer otherwise.
612
613 \note The caller will take the ownership of the returned pointer.
614 */
615 virtual Raster* transform(int srid, double llx, double lly, double urx, double ury, const std::map<std::string, std::string>& rinfo, int m = 1) const;
616
617 /*!
618 \brief Reprojects a squared portion of this raster to another SRS with a desired resolution.
619
620 This method reprojects a squared portion of this raster to another SRS. The number of pixels
621 in the output will be calculated according to the portion being reprojected and the asked resolution.
622
623 \param srid The SRS id of the target SRS.
624 \param llx Lower-left X-coordinate of the portion to be reprojected (in the original SRS).
625 \param lly Lower-left Y-coordinate of the portion to be reprojected (in the original SRS).
626 \param urx Upper-Right X-coordinate of the portion to be reprojected (in the original SRS).
627 \param url Upper-Right Y-coordinate of the portion to be reprojected (in the original SRS).
628 \param resx The output x resolution (in units of the target SRS).
629 \param resx The output y resolution (in units of the target SRS).
630 \param rinfo The parameters needed to build the output raster (see RasterFactory documentation).
631 \param m The method of interpolation to apply (default 1 = nearest neighbor). \sa te::rst::Interpolator
632
633 \return A pointer to the reprojected raster if success and a null pointer otherwise.
634
635 \note The caller will take the ownership of the returned pointer.
636 */
637 virtual 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 = 1) const;
638
639 /*!
640 \brief Vectorizes a given raster band, using GDALPolygonize function.
641
642 \param g A reference to a vector of geometries.
643 Will be filled with geometries found in band.
644 \param b The band index to vectorize.
645
646 \param polygonsValues A pointer to a valid vector where the raster pixel values related to each polygon will be stored, or a NULL pointer.
647
648 \note The caller of this method must take the ownership of the returned geometries and must delete them when necessary.
649 */
650 virtual void vectorize(std::vector<te::gm::Geometry*>& g, std::size_t b, unsigned int mp = 0, std::vector< double > * const polygonsValues = 0);
651
652 /*!
653 \brief Rasterizes a given vector of geometries.
654
655 \param g A vector of geometries to be rasterized.
656 \param vp A vector of pixel values for each geometry.
657 Can have the same size of the vector of geometries, or be null.
658 \param b The band index to rasterize.
659 */
660 virtual void rasterize(std::vector<te::gm::Geometry*> g, std::vector<double> vp, std::size_t b = 0);
661
662 /*!
663 \brief Create a sub-sampled multi-resolution pyramid.
664
665 \param levels The number of pyramid levels to generate.
666 \param interpMethod The used interpolation method.
667
668 \return true if OK, false if errors ocurred.
669 */
670 virtual bool createMultiResolution( const unsigned int levels, const InterpolationMethod interpMethod ) = 0;
671
672 /*!
673 \brief Remove/Destroy a sub-sampled multi-resolution pyramid, if there is one.
674
675 \return true if OK, false if errors ocurred.
676 */
677 virtual bool removeMultiResolution() = 0;
678
679 /*!
680 \brief Returns the current number of multi-resolution pyramid levels.
681
682 \return Returns the current number of multi-resolution pyramid levels.
683 */
684 virtual unsigned int getMultiResLevelsCount() const = 0;
685
686 /*!
687 \brief Returns the required level of a multi-resolution pyramid or NULL if that level does not exists.
688
689 \param level Level of a multi-resolution pyramid.
690
691 \return Returns the required level of a multi-resolution pyramid or NULL if that level does not exists.
692
693 \note The caller must take the ownership of the returned pointer.
694 */
695 virtual Raster* getMultiResLevel( const unsigned int level ) const = 0;
696
697 /*!
698 \brief Sets the raster metadata.
699
700 \param metaData The new raster metadata.
701 */
702 void setMetaData( const std::map<std::string, std::string>& metaData );
703
704 /*!
705 \brief Returns the current raster metadata in a form [metadada name, metadata value].
706
707 \return metaData Returns the current raster metadata.
708 */
709 const std::map<std::string, std::string>& getMetaData() const;
710
711 protected:
712
713 std::string m_name; //!< The raster name.
714 Grid* m_grid; //!< The spatial support for raster data.
715 te::common::AccessPolicy m_policy; //!< The access policy, can be te::common::{NoAccess, RAccess, RWAccess, WAccess}.
716 std::map<std::string, std::string> m_metaData; //!< Raster metadata in a form [metadada name, metadata value].
717
718 /*!
719 \brief Scales a value according to a specific resampling scale.
720
721 \param i The scale to apply.
722 \param v The value to be scaled.
723
724 \return The scaled value.
725 */
726 double applyScale(int i, const double& v) const;
727
728 };
729
730 typedef boost::shared_ptr<Raster> RasterPtr;
731
732 } // end namespace rst
733} // end namespace te
734
735#endif //__TERRALIB_RASTER_INTERNAL_RASTER_H
It implements the vectorizer, based on TerraLib 4 algorithm.
A base class for values that can be retrieved from the data access module.
An Envelope defines a 2D rectangular region.
Definition Envelope.h:52
A raster band description.
Definition Band.h:64
A rectified grid is the spatial support for raster data.
Definition Grid.h:69
An abstract class for raster data strucutures.
Definition Raster.h:72
int getTypeCode() const
It returns the data type code associated to the data value.
Definition Raster.h:362
te::gm::Envelope * getExtent(int srid, te::gm::Envelope *roi=0) const
Returns the geographic extension of the raster data, in a given SRS (distinct from its original one).
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 setAccessPolicy(te::common::AccessPolicy p)
Sets the raster access policy.
virtual const Band * getBand(std::size_t i) const =0
Returns the raster i-th band.
virtual Raster & operator=(const Raster &rhs)
Assignment operator.
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....
virtual Raster * resample(int method, int scale, const std::map< std::string, std::string > &rinfo) const
Resample raster.
virtual void setValues(unsigned int c, unsigned int r, const std::vector< std::complex< double > > &values)
Sets the imaginary attribute values in all complex bands of a cell.
virtual ~Raster()
Virtual destructor.
virtual Raster & operator+=(std::complex< double > &cvalue)
It returns the sum of a constant value to all pixels in the raster.
virtual void setValue(unsigned int c, unsigned int r, const std::complex< double > &value, std::size_t b=0)
Sets the imaginary attribute value in a complex band of a cell.
Grid * getResampledGrid(int scale) const
Return the raster grid for a specific scale.
Raster(Grid *grid, te::common::AccessPolicy p=te::common::RAccess)
Constructor to create a raster from parameters.
virtual const Band & operator[](std::size_t i) const =0
Access band in i position.
void setName(const std::string name)
Sets the raster name.
virtual Raster & operator*=(Raster &rhs)
It returns the raster product (pixel by pixel).
std::map< std::string, std::string > m_metaData
Raster metadata in a form [metadada name, metadata value].
Definition Raster.h:716
Raster(const Raster &rhs)
Copy constructor.
virtual void open(const std::map< std::string, std::string > &rinfo, te::common::AccessPolicy p=te::common::RAccess)=0
Opens a raster.
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
std::string toString(void) const
It returns the data value in a string notation.
virtual unsigned int getMultiResLevelsCount() const =0
Returns the current number of multi-resolution pyramid levels.
virtual Raster & operator+=(Raster &rhs)
It returns the raster sum (pixel by pixel).
const Grid * getGrid() const
It returns the raster grid.
virtual int getBandDataType(std::size_t i) const =0
Returns the data type in a particular band (or dimension).
virtual Raster * trim(const te::gm::Envelope *env, const std::map< std::string, std::string > &rinfo, const std::string &rType) const
Subsetting operation for trimming (cropping) the raster.
double getResolutionY() const
Returns the raster vertical (y-axis) resolution.
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.
virtual Raster * clip(const std::vector< te::gm::Geometry const * > geometries, const std::map< std::string, std::string > &rinfo, const std::string &rType) const
Subsetting operation for clipping the raster.
virtual Raster * getMultiResLevel(const unsigned int level) const =0
Returns the required level of a multi-resolution pyramid or NULL if that level does not exists.
virtual Raster & operator/=(std::complex< double > &cvalue)
It returns the division of all pixels in the raster by a constant value (pixels / constant).
virtual void getValues(unsigned int c, unsigned int r, std::vector< std::complex< double > > &values) const
Returns the imaginary attribute values in all complex bands of a cell.
Grid * getGrid()
It returns the raster grid.
virtual bool removeMultiResolution()=0
Remove/Destroy a sub-sampled multi-resolution pyramid, if there is one.
int getSRID() const
Returns the raster spatial reference system identifier.
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.
Raster & callOperator(std::complex< double >(*f)(std::complex< double >, std::complex< double >), const Raster &rhs)
It calls a parameter function f to apply in all pixels from two rasters, e.g. pixel = f(lhs,...
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.
unsigned int getNumberOfRows() const
Returns the raster number of rows.
virtual Band & operator[](std::size_t i)=0
Access band in i position.
virtual bool createMultiResolution(const unsigned int levels, const InterpolationMethod interpMethod)=0
Create a sub-sampled multi-resolution pyramid.
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.
virtual void rasterize(std::vector< te::gm::Geometry * > g, std::vector< double > vp, std::size_t b=0)
Rasterizes a given vector of geometries.
double getResolutionX() const
Returns the raster horizontal (x-axis) resolution.
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.
virtual void vectorize(std::vector< te::gm::Geometry * > &g, std::size_t b, unsigned int mp=0, std::vector< double > *const polygonsValues=0)
Vectorizes a given raster band, using GDALPolygonize function.
const std::map< std::string, std::string > & getMetaData() const
Returns the current raster metadata in a form [metadada name, metadata value].
virtual 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=1) const
Reprojects a squared portion of this raster to another SRS with a desired resolution.
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 Band * getBand(std::size_t i)=0
Returns the raster i-th band.
virtual Raster & operator-=(std::complex< double > &cvalue)
It returns the difference from all pixels in the raster to a constant value (pixels - constant).
const te::gm::Envelope * getExtent() const
Returns the geographic extension of the raster data.
Grid * m_grid
The spatial support for raster data.
Definition Raster.h:714
te::common::AccessPolicy m_policy
The access policy, can be te::common::{NoAccess, RAccess, RWAccess, WAccess}.
Definition Raster.h:715
Raster()
Default constructor.
virtual Raster & operator-=(Raster &rhs)
It returns the raster subtraction (pixel by pixel).
virtual Raster & operator*=(std::complex< double > &cvalue)
It returns the product of a constant value to all pixels in the raster.
te::gm::Envelope * getExtent()
Returns the geographic extension of the raster data.
void setMetaData(const std::map< std::string, std::string > &metaData)
Sets the raster metadata.
virtual Raster & operator/=(Raster &rhs)
It returns the raster division (pixel by pixel).
double applyScale(int i, const double &v) const
Scales a value according to a specific resampling scale.
std::string m_name
The raster name.
Definition Raster.h:713
virtual void getValue(unsigned int c, unsigned int r, std::complex< double > &value, std::size_t b=0) const
Returns the imaginary attribute value in a complex band of a cell.
virtual std::map< std::string, std::string > getInfo() const =0
It returns additional information about 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.
unsigned int getNumberOfColumns() const
Returns the raster number of columns.
virtual Raster * transform(int srid, double llx, double lly, double urx, double ury, const std::map< std::string, std::string > &rinfo, int m=1) const
Reprojects a squared portion of this raster to a distinct SRS. This method reprojects a squared porti...
const std::string & getName() const
Returns the raster name.
te::common::AccessPolicy getAccessPolicy() const
Returns the raster access policy.
AccessPolicy
Supported data access policies (can be used as bitfield).
Definition Enums.h:41
@ RAccess
Definition Enums.h:43
@ RASTER_TYPE
Definition Enums.h:207
InterpolationMethod
Allowed interpolation methods.
Definition Enums.h:93
boost::shared_ptr< Raster > RasterPtr
Definition Raster.h:730
@ Grid
Definition Enums.h:106
TerraLib.
#define TERASTEREXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition Config.h:63
Proxy configuration file for TerraView (see terraview_config.h).