[R-sig-Geo] accumulate gridcells to a specific value

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Thu Jul 31 11:08:44 CEST 2008


2008/7/31  <Alexander.Herr at csiro.au>:

> I am trying to accumulate gridcells to a specific value. This means I
> need to extent the nearest neighbours (or search radius) to a size so
> that the sum of gridcell values reaches the desired value (or stops if
> sum value of gridcells/radius goes beyond a specific size). It should
> start with the highest gridcell value then next remaining highest etc.
>
> Of course this could also work with points/polygons or on a matrix.
>
> Rather than re-inventing the wheel I was wondering if anyone has or
> knows of a tool/script.

 It's not totally clear what you want to do, but it sounds like the
sort of raster operation that GRASS GIS does.

 http://grass.itc.it/

 Can you explain a bit more about your problem?

 * What are the inputs? Just a grid of values or are there some starting points?
 * What are the outputs? A list of grid cells that add up to your
accumulated value?

 I ask this because this week I wrote some code that did something
very similar, namely:

 Given a grid of resource values and a number of population centres,
compute the areas on the grid that allocate a given resource total to
each population centre by minimising the distance from each centre,
and not allowing any grid square to be allocated to more than one
centre.

 It basically grows areas out from the centres, by finding the minimum
centre-resource cell distance for unallocated cells and allocating
that cell to that centre.

 This was written in Python and used gdal to read grids. Took me a day
to write and a day to document.

 I'll have to start charging for this :)

Barry




More information about the R-sig-Geo mailing list