[GRASS-user] query raster cell and its neighbors by point

Shaun Langley shaunlangley at gmail.com
Thu Mar 14 12:32:25 PDT 2013


Nikos,

Since my input raster is binary (0s and 1s), and I need to know how many of the neighboring cells are 1s, it's sufficient to simply compute the sum of the overall neighborhood.  If I use r.mapcalc to mask out the rest of the raster, I can compute the sum of the entire map with r.sum.  However, since I need to do this for hundreds of points, it seems silly to use such a cumbersome method that will require a lot of processing time.

Shaun
On Mar 14, 2013, at 2:29 PM, Nikos Alexandris <nik at nikosalexandris.net> wrote:

> Shaun Langley wrote:
>> I need to easily query a raster and return both the value of the cell and
>> the aggregate value of the 8-cell neighborhood, given a set of point
>> coordinates.  I know I can easily do this with r.mapcalc, but that involves
>> running the computation for the entire map even though I'm only interested
>> in a very very small portion.  Is there an easier way to do this or am I
>> stuck with the long solution?
> 
> What kind of an aggregation exactly?  Maybe not straight-through, but
> I think you will be "forced" to use G7:
> 
> http://grass.osgeo.org/grass70/manuals/r.neighbors.html
> 
> in a way like
> 
> r.neighbors \
> input=QueriedRaster \
> selection=CellsOfInterest \
> output=AggregatedRaster \
> method=SomeMethod[,MoreMethods,EvenMoreMethods] \
> size=3 \
> title="Aggregated raster map"
> 
> However, you say you need the "queried" cell-value as well. Maybe combine with
> 
> http://grass.osgeo.org/grass70/manuals/r.what
> 
> Best, Nikos



More information about the grass-user mailing list