RasterCalc: from Python to C++
15.10.2010 17:41 · GIS · qgis, plugins, rastercalc
Yesterday I found out that my plugin — RasterCalc — was only announced on the QGIS mailing lists. I didn’t post anything on the forum or here. I don’t know how I could have forgotten. Although I have to admit that there was a lot of work going on at the time: RasterCalc itself, an experimental branch of GDAL Tools, Photo2Shape and many other things. QGIS 1.4 was released in January… I know it’s a weak excuse, especially considering that other plugins were announced all over the place, but I don’t have any others.
So… RasterCalc is a user-friendly and functional raster calculator written in Python. It was announced on the mailing lists on 16 January 2010.
RasterCalc was inspired by Barry Rowlingson’s RasterLang plugin. The main difference is the user-friendly interface and the familiar expression syntax (do you like LISP as much as Barry?). I have also added some additional features like saving and loading expressions, “templates” of formulas and extended the set of available functions and operators.
Weeks and months went by (I almost wrote “years”), nothing seemed to indicate any changes… And then, out of the blue, Marco Hugentobler and Tim Sutton decided to make RasterCalc part of the QGIS analysis library. This will allow its features to be used by other plugins, and remove the dependency on NumPy, pyparsing and other Python modules.
Marco has already published a first version of the patch. Some features are missing compared to the original plugin:
- there is no support for “templates” of formulas (in RasterCalc there are two: “Difference” and “NDVI”)
- the result can only be saved with
Float32
data type - saving and loading of expressions is not supported
At the same time, new features have been added:
- it is possible to specify the desired resolution and extent of the result. This allows rasters with different resolutions to be used in one expression. If necessary, the rasters are automatically resampled to the output resolution
- result can be saved in various formats, not only GeoTiff
You can try out the new functionality by applying the patch and building QGIS from source. The calculator will appear in the “Layer → Raster calculator” menu.
The patch is still under development and some things may not work. The authors invite everyone to try it and report any bugs (if possible, attach a test dataset and steps to reproduce the issue).