[R-sig-Geo] Growing a raster and sum up values

Bernd Vogelgesang bernd.vogelgesang at gmx.de
Fri Mar 21 15:25:55 CET 2014


Dear list,

I'm searching for a solution with R that should replace a now very  
tiresome vector based process in QGIS.
For better understanding, I uploaded a screen-shot:
http://gofile.me/29yAV/7YDnipt9

The situation:
There is a piece of land which will serve as an ecological compensation  
area for building activities in other places.
The area got surveyed and was divided in zones of different ecological  
value, which is described by a credit/m2-system.

In the example, you can see the bigger parts having 25 credits/m2, others  
have 17.
The northern patch is an area with a total of 41200. The investor is  
obliged to compensate an activity somewhere which will cause the loss of  
this amount of credits.

To extract the patch of 41200 credits, I made an overlay with a vector  
grid, then marked some grid cells and used the statist-plugin in QGIS to  
calculate the sum of credits for the selected grid cells. I added and  
removed parts until I approximately got the desired value and then  
exported the selection as a new shape file.

This approach takes a very long time and is very error-prone, plus that I  
have to repair topologies all the time with grass cause there are always  
errors. In the mean-time, the desired values changed, so I have to redo it  
again ...

My idea now was to make things easier by rasterizing the vector and  
finding an algorithm that will grow my patch from a seeding point until it  
reaches the desired credits value.

But ... I have no idea where and how to start.

So my first question would be:
How I can create a one-pixel-raster (by a point coordinate) at a certain  
location above the existing raster, and then let it add pixels to all  
sides (e.g. clockwise) while the underlying raster values get summed up  
until it reaches the desired sum value?

It should not grow outside the underlying raster.

After that, I will try to find out how to implement further logics:
- Respect already created patches (not grow new patch over already  
existent ones).
- Setting a preferred growing direction (left, right , up, down etc.)


I do not expect a working example, just some hints for possible packages  
and buzzwords for further googling. I'm also equipped with Rogers book  
(Though I haven't read it yet ;) ).

Cheers
Bernd


-- 
Bernd Vogelgesang
Siedlerstraße 2
91083 Baiersdorf/Igelsdorf
Tel: 09133-825374



More information about the R-sig-Geo mailing list