28 #define M_PI 3.14159265358979323846
31 #include "../../common/Exception.h"
32 #include "../../common/Translator.h"
33 #include "../../common/progress/TaskProgress.h"
34 #include "../../memory/DataSet.h"
35 #include "../../raster/Grid.h"
36 #include "../../raster/Raster.h"
46 double totKernel = 0.;
76 std::vector<int> results;
77 kTree.
search(ext, results);
80 double val =
KernelValue(params, kMap, radius, coord, results);
106 double radius = 0.68*pow((
double)kMap.size(),-0.2)*sqrt(kTree.
getMBR().
getArea());
124 double totKernel = 0.;
147 std::vector<int> results;
148 kTree.
search(ext, results);
151 double newKernel = 0.;
158 double newRadius = radius * pow((meanKernel / prevKernel), 0.5);
161 if(newRadius > sqArea / 4.)
162 newRadius = sqArea / 4.;
165 newKernel =
KernelValue(params, kMap, newRadius, coord, results);
168 totKernel += newKernel;
171 raster->
setValue(j, i, newKernel, 0);
200 double kernelValue = 0.;
211 rasterOut->
setValue(j, i, kernelValue);
228 double totKernel = 0.;
241 std::auto_ptr<te::gm::Geometry> geom = ds->
getGeometry(geomIdx);
260 std::vector<int> results;
261 kTree.
search(ext, results);
264 double val =
KernelValue(params, kMap, radius, coord, results);
289 double radius = 0.68*pow((
double)kMap.size(),-0.2)*sqrt(kTree.
getMBR().
getArea());
307 double totKernel = 0.;
313 std::auto_ptr<te::gm::Geometry> geom = ds->
getGeometry(geomIdx);
332 std::vector<int> results;
333 kTree.
search(ext, results);
336 double newKernel = 0.;
337 double prevKernel = ds->
getDouble(kernelIdx);
342 double newRadius = radius * pow((meanKernel / prevKernel), 0.5);
345 if(newRadius > sqArea / 4.)
346 newRadius = sqArea / 4.;
349 newKernel =
KernelValue(params, kMap, newRadius, coord, results);
352 totKernel += newKernel;
383 double kernelValue = 0.;
384 double kernelA = dsA->
getDouble(kernelIdx);
385 double kernelB = dsB->
getDouble(kernelIdx);
387 std::auto_ptr<te::gm::Geometry> geom = dsOut->
getGeometry(geomIdx);
394 dsOut->
setDouble(kernelIdx, kernelValue);
430 double normKernel = 0.;
435 normKernel = (kernel * normFactor) / totKernel;
439 normKernel = ((kernel * normFactor) / totKernel) / area;
443 normKernel = kernel / totKernel;
479 std::auto_ptr<te::gm::Geometry> geom = ds->
getGeometry(geomIdx);
483 double kernel = ds->
getDouble(kernelIdx);
485 double normKernel = 0.;
490 normKernel = (kernel * normFactor) / totKernel;
494 normKernel = ((kernel * normFactor) / totKernel) / area;
498 normKernel = kernel / totKernel;
515 double kernelValue = 0.;
517 for(std::size_t t = 0; t < idxVec.size(); ++t)
523 double intensity = kMap[id].second;
549 kernelValue += localK;
557 double kernelValue = 0.;
566 kernelValue = kernelA/kernelB;
575 kernelValue = log(kernelA/kernelB);
581 kernelValue = kernelA - kernelB;
587 kernelValue = (kernelA - kernelB) * area;
593 kernelValue = kernelA + kernelB;
599 kernelValue = (kernelA + kernelB) * area;
612 return intensity * (3.0 / (tau * tau *
M_PI)) *
613 pow(1 - ((distance * distance)/ (tau * tau)),2.0);
618 return intensity * (1.0 / (tau * tau * 2 *
M_PI)) *
619 exp(-1.0 * (distance * distance)/ (2 * tau * tau));
635 return intensity * (1.0 - 1.0/tau) * distance;
643 return intensity * exp(-3.0 * distance);
648 te::sa::KernelMap::iterator it = kMap.begin();
650 double meanMTmp = 0.;
653 while(it != kMap.end())
655 double intensity = it->second.second;
660 double mantissa = frexp(intensity, &exp);
662 meanMTmp += log(mantissa);
669 double meanM = (meanMTmp + (meanETmp * log(2.))) / kMap.size();
TESAEXPORT void GridRatioKernel(te::sa::KernelOutputParams *params, te::rst::Raster *rasterA, te::rst::Raster *rasterB, te::rst::Raster *rasterOut)
Evaluates kernel ratio value using a raster as output data.
std::size_t size() const
It returns the collection size, if it is known.
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.
TESAEXPORT void DataSetRatioKernel(te::sa::KernelOutputParams *params, te::mem::DataSet *dsA, te::mem::DataSet *dsB, te::mem::DataSet *dsOut, int kernelIdx, int geomIdx)
Evaluates kernel ratio value using a dataset as output data.
std::auto_ptr< te::gm::Geometry > getGeometry(std::size_t i) const
Method for retrieving a geometric attribute value.
void setMessage(const std::string &message)
Set the task message.
TESAEXPORT void GridAdaptRadiusKernel(te::sa::KernelInputParams *params, te::sa::KernelTree &kTree, te::sa::KernelMap &kMap, te::rst::Raster *raster)
Evaluates kernel value using a raster as output data and a adaptative value for radius.
Functions used in statistics operations.
TESAEXPORT void GridKernelNormalize(te::sa::KernelInputParams *params, te::sa::KernelMap &kMap, te::rst::Raster *raster, double totKernel)
Normalizes kernel values based on type of estimation.
TESAEXPORT void GridStatRadiusKernel(te::sa::KernelInputParams *params, te::sa::KernelTree &kTree, te::sa::KernelMap &kMap, te::rst::Raster *raster, double radius)
Evaluates kernel value using a raster as output data and a fixed value for radius.
unsigned int getNumberOfColumns() const
Returns the raster number of columns.
This class can be used to inform the progress of a task.
TESAEXPORT double KernelQuartic(double tau, double distance, double intensity)
Kernel functions for Quartic type.
std::map< int, std::pair< te::gm::Geometry *, double > > KernelMap
double m_urx
Upper right corner x-coordinate.
TESAEXPORT te::gm::Coord2D GetCentroidCoord(te::gm::Geometry *geom)
Function used to get centroid coord of a geometry.
TESAEXPORT double KernelUniform(double tau, double distance, double intensity)
Kernel functions for Uniform type.
An utility struct for representing 2D coordinates.
This file contains a functions used by the kernel operation.
TESAEXPORT double KernelValue(te::sa::KernelInputParams *params, te::sa::KernelMap &kMap, double radius, te::gm::Coord2D &coord, std::vector< int > idxVec)
Evaluates kernel value of events with intensity.
#define TE_TR(message)
It marks a string in order to get translated.
Utilitary function for spatial analysis module.
Class that represents the kernel output parameters.
bool isActive() const
Verify if the task is active.
TESAEXPORT void DataSetAdaptRadiusKernel(te::sa::KernelInputParams *params, te::sa::KernelTree &kTree, te::sa::KernelMap &kMap, te::mem::DataSet *ds, int kernelIdx, int geomIdx)
Evaluates kernel value using a dataset as output data and a adaptative value for radius.
void setTotalSteps(int value)
Set the task total stepes.
TESAEXPORT double GetArea(te::gm::Geometry *geom)
Function used to get area of a geometry.
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
double m_llx
Lower left corner x-coordinate.
TESAEXPORT double Sum(te::sa::GeneralizedProximityMatrix *gpm, int attrIdx)
Function used to calculate sum of a specific attribute from a gpm.
An Envelope defines a 2D rectangular region.
An abstract class for raster data strucutures.
TESAEXPORT double KernelRatioValue(te::sa::KernelOutputParams *params, double area, double kernelA, double kernelB)
Evaluates kernel ratio value.
unsigned int getNumberOfRows() const
Returns the raster number of rows.
double getResolutionX() const
Returns the raster horizontal (x-axis) resolution.
double getArea() const
It returns the area of this envelope as measured in the spatial reference system of it...
void pulse()
Calls setCurrentStep() function using getCurrentStep() + 1.
int search(const te::gm::Envelope &mbr, std::vector< DATATYPE > &report) const
Range search query.
TESAEXPORT double KernelTriangular(double tau, double distance, double intensity)
Kernel functions for Triangular type.
Grid * getGrid()
It returns the raster grid.
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
te::sa::KernelCombinationType m_combinationType
Kernel combination type (used by ratio kernel)
TESAEXPORT void DataSetKernelNormalize(te::sa::KernelInputParams *params, te::sa::KernelMap &kMap, te::mem::DataSet *ds, int kernelIdx, int geomIdx, double totKernel)
Normalizes kernel values based on type of estimation.
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.
double m_lly
Lower left corner y-coordinate.
bool moveBeforeFirst()
It moves the internal pointer to a position before the first item in the collection.
bool moveNext()
It moves the internal pointer to the next item of the collection.
const te::gm::Envelope & getMBR(void) const
It returns the bounding box of all elements in the tree.
double getDouble(std::size_t i) const
Method for retrieving a double attribute value.
double m_ury
Upper right corner y-coordinate.
void gridToGeo(const double &col, const double &row, double &x, double &y) const
Get the spatial location of a grid point.
double getResolutionY() const
Returns the raster vertical (y-axis) resolution.
TESAEXPORT double CalculateDistance(te::gm::Geometry *geom, te::gm::Coord2D &coord)
Function used to calculate the distance from a coord to the center of a geometry. ...
TESAEXPORT void DataSetStatRadiusKernel(te::sa::KernelInputParams *params, te::sa::KernelTree &kTree, te::sa::KernelMap &kMap, te::mem::DataSet *ds, int kernelIdx, int geomIdx, double radius)
Evaluates kernel value using a dataset as output data and a fixed value for radius.
void setDouble(std::size_t i, double value)
TESAEXPORT double KernelNegExponential(double tau, double distance, double intensity)
Kernel functions for Negative Exponential type.
TESAEXPORT double KernelNormal(double tau, double distance, double intensity)
Kernel functions for Normal type.
TESAEXPORT double KernelGeometricMean(te::sa::KernelMap &kMap)
Calculates the geometric mean from kernel map (intensity value) using log.