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

Shaun Langley shaunlangley at gmail.com
Thu Mar 14 12:42:30 PDT 2013



> 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?
> 
> Nikos Alexandris wrote:
>> 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
> 
> Maybe combine all this with a MASK? i.e., create buffer(s) around your 
> coordinates of interest, use r.what and r.neighbors then?

Ah!  I think I see what you're saying.  If I create a new raster where all cells are replaced by the sum of their neighbors, then I can run queries for each point without having to recompute the neighborhood.  This might work.  Is this what you had in mind?

> (@MMetz -- maybe of your interest?) 
> And, at this point comes the idea:  why not let r.neighbors, when a 
> "selection=RasterMap" is defined, return in an extra raster map the one-central 
> queried cell?
> 



More information about the grass-user mailing list