I have used zonal statistics from processing to calculate the raster statastics with polygon layer.
processing.runalg('qgis:zonalstatistics', rlayersource, 1, vlayer, None, True, Path)
But this is taking more time if the no of polygon blocks are more. So i found that we can use numpy
and scipy
to calculate the statistics of the raster.
How can i do that?
rasterstats
package to be quite a bit faster than QGIS' implementation of raster statistics.Maybe take a look at that before you try to reinvent the wheel in Python.