Re: [Qgis-developer] Raster algebra C++
Hi Martin Thanks for looking at the patch. Your point about the search string makes sense. I decided to use the search string because of code reusage and the idea of introducing some comparison operators for raster algebra in the future (e.g. ras...@1 10 would return a raster with 1 for values over 10 and 0 for values below). But now, looking at the searchtreenode, I realise that it wouldn't be possible to use checkAgainst() for that since it returns a bool. So yes, semantics is different. Regards, Marco Am Montag, 18. Oktober 2010, um 19.41:41 schrieb Martin Dobias: Hi Marco On Thu, Oct 14, 2010 at 5:40 PM, Marco Hugentobler marco.hugentob...@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. [...] 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'. Thanks a lot for the patch. I have taken a brief look on it and I have one suggestion: IMHO it would be better to keep the parser (and interpreter) for raster algebra and search strings separate. I understand that it is easier to reuse some of the code from search strings with raster algebra, but the semantics is very different. And there are various functions and operators that work only for one of them, so mixing them together complicates the inner working of the search string interpreter. Extending the languages (e.g. usage of raster neighborhood, further string operations) will make the code even more cluttered. My vision is that search strings should continue to evolve to support a reasonable subset of SQL language, while raster algebra language can evolve to support further raster/matrix operations. Keeping these different languages separately may bring brighter future for both :-) Regards Martin -- Dr. Marco Hugentobler Sourcepole - Linux Open Source Solutions Webereistrasse 66, 8134 Adliswil, Switzerland marco.hugentob...@sourcepole.ch http://www.sourcepole.ch Technical Advisor QGIS Project Steering Committee ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [Qgis-developer] Raster algebra C++
the same problem arises in the vector calculation dialog. I had to rename the vector fields. Ghislain On 10/14/2010 08:09 PM, Alexander Bruy wrote: And another minor issue. I have raster 2007.tif. When I enter expression 2...@1 + 2...@2 I get Expression invalid message. Seems that raster names only with digits and symbols minus (-) don't recognized as valid raster names ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [Qgis-developer] Raster algebra C++
Hi Marco On Thu, Oct 14, 2010 at 5:40 PM, Marco Hugentobler marco.hugentob...@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. [...] 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'. Thanks a lot for the patch. I have taken a brief look on it and I have one suggestion: IMHO it would be better to keep the parser (and interpreter) for raster algebra and search strings separate. I understand that it is easier to reuse some of the code from search strings with raster algebra, but the semantics is very different. And there are various functions and operators that work only for one of them, so mixing them together complicates the inner working of the search string interpreter. Extending the languages (e.g. usage of raster neighborhood, further string operations) will make the code even more cluttered. My vision is that search strings should continue to evolve to support a reasonable subset of SQL language, while raster algebra language can evolve to support further raster/matrix operations. Keeping these different languages separately may bring brighter future for both :-) Regards Martin ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [Qgis-developer] Raster algebra C++
Hi Our community prepare QGIS binaries with raster algebra patch for OSGeo4W users who want to test this great improvement. Here is a short installation instructions: 1. install qgis-dev with all dependencies from OSGeo4W 2. download archieve with binaries (~8.2 Mb compressed with 7-zip) http://gis-lab.info/share/alexbruy/qgis-calc-r14380.7z 3. unpack it in OSGeo4W root folder (C:\OSGeo4W by default) 4. open OSGeo shell and run qgis-calc.bat -- Alexander Bruy ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [Qgis-developer] Raster algebra C++
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@@q...@xz) referenced in function private: void __thiscall QgisApp::showRasterCalculator(void) (?showrastercalcula...@qgisapp@@AAEXXZ) qgisapp.obj : error LNK2019: unresolved external symbol public: int __thiscall QgsRasterCalculator::processCalculation(class QProgressDialog *) (?processcalculat...@qgsrastercalculator@@QAEHPAVQProgressDialog@@@Z) referenced in function private: void __thiscall QgisApp::showRasterCalculator(void) (?showrastercalcula...@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 QVectorstruct QgsRasterCalculatorEntry const ) (??0QgsRasterCalculator@@q...@abvqstring@@00ABVQgsRectangle@@hhabv?$qvec...@uqgsrastercalculatorentry@Z) referenced in function private: void __thiscall QgisApp::showRasterCalculator(void) (?showrastercalcula...@qgisapp@@AAEXXZ) On Linux I compile this without errors. Thanks On Thu, 14 Oct 2010 17:40:03 +0200 Marco Hugentobler marco.hugentob...@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 '-10'. - 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 Webereistrasse 66, 8134 Adliswil, Switzerland marco.hugentob...@sourcepole.ch http://www.sourcepole.ch Technical Advisor QGIS Project Steering Committee ___
Re: [Qgis-developer] Raster algebra C++
And another minor issue. I have raster 2007.tif. When I enter expression 2...@1 + 2...@2 I get Expression invalid message. Seems that raster names only with digits and symbols minus (-) don't recognized as valid raster names -- Alexander Bruy ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [Qgis-developer] Raster algebra C++
Hi Alexander, On Thu, 14. Oct 2010 at 20:58:01 +0300, Alexander Bruy wrote: I change line 1304 as res[i] = pow(double(value1), double(mat[i])); value1 is already double. So casting mat[i] should be enough. and the I get another errors: qgisapp.obj : error LNK2019: unresolved external symbol public: __thiscall QgsRasterCalculator::~QgsRasterCalculator(void) (??1QgsRasterCalculator@@q...@xz) referenced in function private: void __thiscall QgisApp::showRasterCalculator(void) (?showrastercalcula...@qgisapp@@AAEXXZ) qgisapp.obj : error LNK2019: unresolved external symbol public: int __thiscall QgsRasterCalculator::processCalculation(class QProgressDialog *) (?processcalculat...@qgsrastercalculator@@QAEHPAVQProgressDialog@@@Z) referenced in function private: void __thiscall QgisApp::showRasterCalculator(void) (?showrastercalcula...@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 QVectorstruct QgsRasterCalculatorEntry const ) (??0QgsRasterCalculator@@q...@abvqstring@@00ABVQgsRectangle@@hhabv?$qvec...@uqgsrastercalculatorentry@Z) referenced in function private: void __thiscall QgisApp::showRasterCalculator(void) (?showrastercalcula...@qgisapp@@AAEXXZ) Add ANALYSIS_EXPORT to the QgsRasterCalculator declaration in src/analysis/raster/qgsrastercalculator.h:39: class ANALYSIS_EXPORT QgsRasterCalculator Jürgen -- Jürgen E. Fischer norBIT GmbH Tel. +49-4931-918175-20 Dipl.-Inf. (FH) Rheinstraße 13Fax. +49-4931-918175-50 Software Engineer D-26506 Norden http://www.norbit.de -- norBIT Gesellschaft fuer Unternehmensberatung und Informationssysteme mbH Rheinstrasse 13, 26506 Norden GF: Jelto Buurman, HR: Amtsgericht Emden, HRB 5502 ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer