|
Hi Tim, On 17/10/2010 21:36, Tim Sutton wrote: Well it is not in the PyQt (4.6.2) API doc I'm using!Hi On Sun, Oct 17, 2010 at 7:15 PM, Benoit de Cabissole <[email protected]> wrote:Hi Tim,Many thanks for your reply. I see that the API doc classifies HistogramVector as a QVector but I cannot find any reference of QVector in the Qt doc (there are QVector2D, QVector3D and QVector4D). Could it be the problem?I found QVector in my (Qt 4.7) docs using Qt Assistant - not sure why its not showing up for you. Perhaps it is not ported to the python SIP lib. Thanks!What I'm trying to do is to improve the speed of my plugin '1-band raster colour table' that allows to create colour table from a colour palette and a colouring method.Yup I use your plugin regularly - its great! Oh no! I'm also using two passes, because I need to compute the min/max in the first pass to compute the classes for the histogram in the second pass.As I'm doing it in Python, the computation of the stats and histogram takes for ever on large rasters. I was hoping to piggyback on the stats and histo function built in QGIS (they themselves are (very) slow on large rasters).Right this is an issue. Part of the reason why QGIS is so slow is that it actually does two complete scans of each pixel to calculate the stats. This is needed for computing stddev - although since writing that code I have seen a way to compute stddev in a single pass - I just need to find the formula and the time to implement that. The STDev that I use is computed in a single pass with the following formula: STD = SQRT( ( N * Sum(X^2) - (Sum(X))^2 ) / ( N * (N-1) ) ) Note that Sum(X^2) is the 'sum of uncentered squares', not the one presently computed by QGIS/GDAL. Manuel Massing has said that QGIS/GDAL computes the 'empirical variance of the data' (i.e. sum (value-mean)2 ) and calls it the 'sum of the squared values'. So between us two we could reduce the time by having only one loop! How do you compute the histogram in one pass? Do you, a priori, know the max and min values? Are they available when the raster is loaded? I know an estimate of them is available. Yes, I've noticed that one. Is there a function in QGIS to read its content in one go? Or do I have to parse it myself?GDAL computes stats more quickly as it a) doesnt calculate stddev and b) will estimate things like min/max, histograms etc if you like based on a sampling of the data. GDAL can also store gathered stats (you may have noticed aux.xml files lying around in your raster dirs). For version 1.x of the plugin, I've eliminated the "imagette" (as Agus calls it) and replaced it by a new temporary layer in the mapcanvas because I'm now using QGIS functions to display the raster instead of my very slow matrix based raster used in the published plugin. Problem now is that QGIS compute the stats for that temp raster each time it is launched, and it can be very very slow. Is there a way to tell QGIS to use an (arbitrary) aux.xml file instead of computing the stats the first time the colour table changes? In my experience rasters files rarely change so keeping the stats file for that raster somewhere close to it would be a good idea, isn't it? In the longer term I would like to a) persist QGIS gathered stats, b) implement faster stddev calcs as mentioned above and c) only compute IO intensive stats like stddev if they are actually needed (e.g. if the user elects to use stddev in the raster symbology options).I agree that this work should be patched to the current code, but I'm not able to program in C++/C... So once the python plugin works as expected, it would be a good idea to hand it over to a C++ guru for patching!Yeah if I have time I may take a look - your plugin is really needed in the core of QGIS. Please before doing that wait for version 1.x it could be better to do the translation on it rather than on the current version. Cheers, Benoit Regards Tim |
_______________________________________________ Qgis-developer mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/qgis-developer
