# [GRASS-user] zonal statistics for multiple areas

Nikos Alexandris nik at nikosalexandris.net
Mon Oct 29 15:46:57 PDT 2018

```Resending, as I forgot to Cc the list.

* Alessandro Sebastiani <alessandro.sebastiani at uniroma1.it> [2018-10-29 16:05:54 +0100]:

>Hello to everybody,o

Hello Alessandro,

>I hope my question is appropriate for this mail list. I have created 5
>different buffer layers (d=100,200,300,400,500 m) from a point vector. Now
>i want to compute some zonal statistics using different rasters as input.

You are in the right place. And the first guess is that what you need to
do is not difficult using GRASS GIS.

Which rasters exactly?  Would you want to use as base maps each of the
'0 to 100 m', '100 to 200 m' and so on "buffers"  or  '0 to 100 m', '0
to 200 m' and so on up to '0 to 500 m'?  And then, the 'other' maps
would be the 'cover' map, each time?

If you share exactly what you need to do, i.e. in form of an algorithm
using pseudo-syntax, it will be easier to understand and potentially
suggest ways to get this done.

For example:

```
for each Buffer in Buffers:
compute zonal statistics using base=Buffer and cover=RasterX
```

For example, you might be able to get part of this done using raster maps
only and `r.mapcalc` expressions, without the need to construct many loops and
require an extra step in the end to patch maps together.

>I know how to do that separately, but i was wondering how could i automate
>this procedure using a python script.

If you write down the way to do it separately, then you are just few
steps away in looping over your input rasters.  The key point is,
obviously, to express what is to be done in an unambiguous way.

>I know python's basics, but i was not
>able to do so following guidelines that i found on the internet, e.g GRASS
>tutorial.

Please share which guidelines, i.e. which GRASS GIS tutorial you refer
to.

Nikos
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20181029/22de2e03/attachment.sig>
```