3

I have 12000 circles with a radius of 50 miles on a raster with 0.05 degree resolution. Global analysis. The raster is 32 bit float and I have to calculate zonal statistics for 20 different rasters. Each calculation takes approximately 6 hours in QGIS on my local machine (16GB RAM, 4 cores i7, windows OSGeo4W suite). Looking for best ways to speed up. I do have limited knowledge of spinning up cloud instances with Linux. Options are:

  • multiprocessing on local machine
  • Linux instances with rasterstats (running into problems while installing on Linux instance using pip)
  • Linux instances with QGIS toolbox (having problems calling the processing toolbox. Zonal stats by QGIS is preferred over the SAGA one)
  • Linux instances with other tools/libraries??
  • Windows server with ArcPy capabilities

What flavour to choose? I'm using Python 2.7 as scripting language

3

You could run a benchmark test between QGIS and pktools and specifically pkextract (extract pixel values from raster image from a (vector or raster) sample) to see if it is faster when run directly from the command-line. The usage of the tool is outlined on the above-mentioned link, but in general terms it is:

pkextract -f 'ESRI Shapefile' -s vector_aoi.shp -i input_raster.tif 
-o output_vector_with_stats.shp -polygon --rule mean

Note pkextract provides a set of rules that include: centroid, mean, stdev, median, proportion, count, min, max, mode, sum, percentile

pktools can be installed on Debian using apt-get or using the pkools_install_script on Ubuntu and other Unix distributions.

If you need to speed this process up, consider using xargs on linux.

  • It works. I am the using subprocess module in python with shell=true to get the results – RutgerH Jan 14 '16 at 20:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.