[GRASS-user] How to print a table with the values of a given raster layer aggregated by a second raster layer ?

Let’s say in grass I have a raster layer “regionId” and a raster layer “forestArea”.

In the regionId I have stored the ids of the regions, in the forestArea I stored the square km of forest within the pixel.

How can I print a table summing up the forest area by region, that is the sum of the values of a layer aggregated (“group by”) by a second layer ?

Cheers,

Antonello

···

Antonello Lobianco
AgroParisTech, Laboratoire d’Economie Forestière
14 Rue Girardet - 54000 Nancy, France
Tel: +33.383396865
Email: antonello.lobianco@nancy.inra.fr
http://antonello.lobianco.org

Hei Antonello,

Have a look at r.univar (https://grass.osgeo.org/grass70/manuals/r.univar.html)

And the zone option.

Cheers

Stefan

···

Let’s say in grass I have a raster layer “regionId” and a raster layer “forestArea”.

In the regionId I have stored the ids of the regions, in the forestArea I stored the square km of forest within the pixel.

How can I print a table summing up the forest area by region, that is the sum of the values of a layer aggregated (“group by”) by a second layer ?

Cheers,

Antonello

Antonello Lobianco
AgroParisTech, Laboratoire d’Economie Forestière
14 Rue Girardet - 54000 Nancy, France
Tel: +33.383396865
Email: antonello.lobianco@nancy.inra.fr
http://antonello.lobianco.org

On Mon, Sep 19, 2016 at 6:41 PM, Antonello Lobianco
<antonello@lobianco.org> wrote:

Let's say in grass I have a raster layer "regionId" and a raster layer
"forestArea".

In the regionId I have stored the ids of the regions, in the forestArea I
stored the square km of forest within the pixel.

How can I print a table summing up the forest area by region, that is the
sum of the values of a layer aggregated ("group by") by a second layer ?

Please take a look at
https://grasswiki.osgeo.org/wiki/Zonal_statistics

There are several options.

Best
Markus

Thanks all to have pointed me to the right pages. I solved with the r.univar command:

r.univar -t map=forestArea zones=regionId separator=comma output=forestArea_by_region.csv

Cheers,

/Antonello

···

On 19 September 2016 at 21:59, Markus Neteler <neteler@osgeo.org> wrote:

On Mon, Sep 19, 2016 at 6:41 PM, Antonello Lobianco
<antonello@lobianco.org> wrote:

Let’s say in grass I have a raster layer “regionId” and a raster layer
“forestArea”.

In the regionId I have stored the ids of the regions, in the forestArea I
stored the square km of forest within the pixel.

How can I print a table summing up the forest area by region, that is the
sum of the values of a layer aggregated (“group by”) by a second layer ?

Please take a look at
https://grasswiki.osgeo.org/wiki/Zonal_statistics

There are several options.

Best
Markus

Antonello Lobianco
AgroParisTech, Laboratoire d’Economie Forestière
14 Rue Girardet - 54000 Nancy, France
Tel: +33.383396865
Email: antonello.lobianco@nancy.inra.fr
http://antonello.lobianco.org