[GRASS-user] zone statistics ?

Hi,

Is it possible to get kind of zonal statistics in Grass ? I don't know
if the term is the rigth one, but here is what I want to do.

I have two vector layers. I want to update the first layer using
information from the second layer.

Ex.
Layer_2 is a network of cells with an average pumping rate.

If cell_1 of layer_1 overlaps cell_2 and cell_3 in layer_2, I want the
average pumping rate of cell_1 to be a spatial mean of the pumping rates
of cell_2 and cell_3 according to their surface in cell1.

Is it clear enough ?

I'm sure there is a pretty straigthforward way to do this in grass but I
haven't found it.

Thank you all in advance for the help.

Didrik

Ps : I'm running Grass 6.2.0 (Debian/Sid).

Hi Didrik,

On Monday 08 January 2007 05:29, Didrik Pinte wrote:

Hi,

Is it possible to get kind of zonal statistics in Grass ? I don't know
if the term is the rigth one, but here is what I want to do.

I think that zonal statistics are usually defined in terms of

Univariate statistics computed from some source raster, within zones as
defined by either raster or vector data. I do not think that having only
vector data as input should be a problem.

I have two vector layers. I want to update the first layer using
information from the second layer.

Ex.
Layer_2 is a network of cells with an average pumping rate.

'network of cells' ?? what exactly does this mean? are these points, polygons?

If cell_1 of layer_1 overlaps cell_2 and cell_3 in layer_2, I want the
average pumping rate of cell_1 to be a spatial mean of the pumping rates
of cell_2 and cell_3 according to their surface in cell1.

what is Layer_1 ? some sort of polygon boundary?

Is it clear enough ?

not for me.

I'm sure there is a pretty straigthforward way to do this in grass but I
haven't found it.

Thank you all in advance for the help.

Didrik

Ps : I'm running Grass 6.2.0 (Debian/Sid).

I the solution in GRASS is most likely a raster operation, so careful
conversion with v.to.rast and r.to.vect might be required for at least one
layer. Optionally, if your zones are defined with polygon data, and
your 'data_to_be_summarized' are raster- then a program called 'starspan' may
be of interest to you.

Good luck,

Dylan

--
Dylan Beaudette
Soils and Biogeochemistry Graduate Group
University of California at Davis
530.754.7341

Hi Didrik,

Didrik Pinte escribió:

I have two vector layers. I want to update the first layer using
information from the second layer.

Ex.
Layer_2 is a network of cells with an average pumping rate.

If cell_1 of layer_1 overlaps cell_2 and cell_3 in layer_2, I want the
average pumping rate of cell_1 to be a spatial mean of the pumping rates
of cell_2 and cell_3 according to their surface in cell1.
  

I hope I understood what you want to do: ¿Some kind of weightend cuadrat count method based in polygons instead of points?

This task we can do with the following three steps
(maybe there exists a shorter version, but this works):

1. An overlay of the two vector maps
2. Make a new table with the spatial mean of the pumping rate (database task)
3. Join the new table with the second layer

Before starting we need to get shure that layer_2 (pumping rates) has the following atributes: the area of the cells (v.to.db, call it "area_tot") and the pumping_rate.

1. v.overlay with the two vector layers. -> intersection, so the operator is 'and'
Now we need to add two new columns, one with the area of the new poligons (v.to.db, call it "area_new") and the second with the weightend_pumping_rate (area_new / area_tot * pumping_rates). Thats the pumping rate in the new polygons created by the intersection.

2. The output-table of the overlay has the cat values of the cells in layer_1 and also the fields area_new and weightend_pumping_rate from the overlay.
With this table we create a new one to calculate the "spatial mean of the pumping rates" for every cell in layer_1.
We are going to do 2 pure database-steps, so you don't have to, but you can do it in GRASS (db.execute):
a) first we create a new table with 3 columns (cat_layer_1, sum_weightend_pumping_rate, sum_area_new) to summarize the values of the weightend_pumping_rate and area_new columns grouped by cat_layer_1 (SQL: SUM; GROUP BY).
b) In the new table we add an other column avarage_pump_rate: SUM_weightened_pumping_rate / SUM_area_new.
Now we have the spatial mean of the pumping-rates for every cat of layer_1.

3. And the last step: we join the original layer_1 with the new table, the cat-field as key.

thats it

I hope it was useful

cheers,
jan