[Qgis-developer] Raster algebra C++

Marco Hugentobler marco.hugentobler at sourcepole.ch
Sat Oct 16 04:48:56 EDT 2010


Hi Alexander and Jürgen

Thanks for your feedback and testing. I'm going to be out of contact for the 
next week (holydays in the mountains) and will probably do some further 
testing and cleaning of the sources, then publish an updated patch. 

It would be cool to have it in trunk after the 1.6 feature freeze.

Regards,
Marco



Am Donnerstag, 14. Oktober 2010, um 19.58:01 schrieb Alexander Bruy:
> Hi Marco,
> 
> seems that this is another great addition from your side.
> 
> I'll try to build QGIS trunk (r14380) with this patch under
> Windows with MSVS Express 2008 and dependencies from OSGeo4W
> and get next error:
> 
> qgssearchtreenode.cpp
> d:\devel\cpp\qgis\trunk\src\core\qgssearchtreenode.cpp(1304) : error C2666:
> 'pow' : 6 overloads have similar conversions c:\program files\microsoft
> visual studio 9.0\vc\include\math.h(575): could be 'long double pow(long
> double,int)' c:\program files\microsoft visual studio
> 9.0\vc\include\math.h(573): or 'long double pow(long double,long double)'
> c:\program files\microsoft visual studio 9.0\vc\include\math.h(527): or
> 'float pow(float,int)' c:\program files\microsoft visual studio
> 9.0\vc\include\math.h(525): or 'float pow(float,float)' c:\program
> files\microsoft visual studio 9.0\vc\include\math.h(489): or 'double
> pow(double,int)' c:\program files\microsoft visual studio
> 9.0\vc\include\math.h(123): or 'double pow(double,double)' while trying to
> match the argument list '(double, float)'
> 
> I change line 1304 as
>  res[i] = pow(double(value1), double(mat[i]));
> 
> and the I get another errors:
> 
> qgisapp.obj : error LNK2019: unresolved external symbol "public: __thiscall
> QgsRasterCalculator::~QgsRasterCalculator(void)"
> (??1QgsRasterCalculator@@QAE at XZ) referenced in function "private: void
> __thiscall QgisApp::showRasterCalculator(void)"
> (?showRasterCalculator at QgisApp@@AAEXXZ) qgisapp.obj : error LNK2019:
> unresolved external symbol "public: int __thiscall
> QgsRasterCalculator::processCalculation(class QProgressDialog *)"
> (?processCalculation at QgsRasterCalculator@@QAEHPAVQProgressDialog@@@Z)
> referenced in function "private: void __thiscall
> QgisApp::showRasterCalculator(void)"
> (?showRasterCalculator at QgisApp@@AAEXXZ) qgisapp.obj : error LNK2019:
> unresolved external symbol "public: __thiscall
> QgsRasterCalculator::QgsRasterCalculator(class QString const &,class
> QString const &,class QString const &,class QgsRectangle const
> &,int,int,class QVector<struct QgsRasterCalculatorEntry> const &)"
> (??0QgsRasterCalculator@@QAE at ABVQString@@00ABVQgsRectangle@@HHABV?$QVector
> @UQgsRasterCalculatorEntry@@@@@Z) referenced in function "private: void
> __thiscall QgisApp::showRasterCalculator(void)"
> (?showRasterCalculator at QgisApp@@AAEXXZ)
> 
> On Linux I compile this without errors.
> 
> Thanks
> 
> On Thu, 14 Oct 2010 17:40:03 +0200
> 
> Marco Hugentobler <marco.hugentobler at sourcepole.ch> wrote:
> > Hi devs,
> > 
> > A very cool and handy tool is Alexander Bruys raster algebra plugin. It's
> > so usefull in environmental modelling that Tim and I thought it would be
> > good to have it in our analysis library (where it can be used by 3rd
> > party applications too and without the dependency of the numpy library).
> > So here is my initial patch that implements a calculator tool as part of
> > the analysis library by extending the search string mechanism.
> > 
> > 
> > Compared to the python plugin, is has some missing features (but they
> > could be added):
> > - no 'difference' and 'NDVI' buttons
> > - only outputs float32 rasters
> > - no possibility to load / save expressions
> > 
> > On the other side, it has some additional features:
> > - Possibility to insert output extent and resolution and do calculations
> > with layers that have different resolutions / extent. If a layer
> > resolution does not match, it is automatically resampled to the output
> > resolution (of course with higher computation costs)
> > - Selection of output format
> > 
> > 
> > You can try the functionality by applying the following patch:
> > http://karlinapp.ethz.ch/101014_qgis_rastercalculator.diff
> > The menu to open the calculator is located under 'Layer->Raster
> > calculator'.
> > 
> > I didn't apply it to trunk directly, as it needs more testing and there
> > are still some issues:
> > 
> > - Flex detects a string as raster if it has '@' followed by a single
> > number (the raster band number). Don't know if there are better
> > solutions, especially to avoid conflicts with vector columns named that
> > way.
> > 
> > - QgsSearchTreeValue is extended with a new type to represent a raster
> > matrix and with new operators and methods doing matrix operations. This
> > class needs some code cleaning before applying to trunk
> > 
> > - Handling of nodata values could be done in a more clever way: out of
> > band values during resampling receive the nodata value of the input
> > raster band. In case of error (e.g. division through zero),
> > QgsSearchStingValue applies '-100000'.
> > 
> > - More testing is needed. Especially with the automatic resampling
> > option, there is a high risk for rounding errors. Send me a mail if you
> > found a bug (possibly with a sample dataset and easy instruction on how
> > to reproduce).
> > 
> > 
> > Looking forward for your feedback,
> > Marco


-- 
Dr. Marco Hugentobler
Sourcepole - Linux & Open Source Solutions
Webereistr. 66, CH-8134 Adliswil, Switzerland
marco.hugentobler at sourcepole.ch http://www.sourcepole.ch
Technical Advisor QGIS Project Steering Committee


More information about the Qgis-developer mailing list