[GRASS-user] zone statistics ?

Jan Schorn js.mailinglists at gmail.com
Mon Jan 8 19:29:05 EST 2007


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




More information about the grass-user mailing list