[GRASS-user] query raster cell and its neighbors by point
Nikos Alexandris
nik at nikosalexandris.net
Thu Mar 14 13:04:02 PDT 2013
[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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 230 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20130314/ae596ac1/attachment.pgp>
More information about the grass-user
mailing list