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

Shaun Langley shaunlangley at gmail.com
Thu Mar 14 13:48:02 PDT 2013


Thanks Nikos,

I'm going to try the G7 approach.  I do need both cell values and neighbor values, but figured I would just run the computation twice.  

Thanks!
Shaun


On Mar 14, 2013, at 3:04 PM, Nikos Alexandris <nik at nikosalexandris.net> wrote:

> [meant to hit the list as well!]
> 
> 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.
> 
> Nikos Alexandris wrote:
>>>> What kind of an aggregation exactly?  Maybe not straight-through, but
> 
> Shaun Langley wrote:
>>> 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. 
> 
> Since you have a binary map (as you wrote in your latest post), all easier (me 
> thinks).
> 
> r.neighbors (in G7) can do that:
> 
> # turn your co-ordinates into a raster map if they aren't already
> # ...simply a binary would be sufficient I guess
> 
> # sum the 8 neighbors for each point of interest
> r.neighbors input=QueriedRaster selection=CellsOfInterest 
> output=SumOf8Neighbors method=sum
> 
> However, I got confused a bit because a) I though it's a more complex map than 
> binary/boolean and b) you asked also for returning "the value of the cell"...
> 
> If your binary map is a "True/False" map, why not setting all those 0s to NULL 
> (using "r.null setnull=0")?  Then, if your Raster-To-Be-Queried has only 1s, 
> then you know that it's always "1" the cell that is queried (if it is not 
> NULL).
> 
> I hope I got it right what you are after.
> Best, Nikos



More information about the grass-user mailing list