[GRASS-user] Looking for a Grass equivalent to ESRI's Focalmean(grid, ANNULUS, irad, orad)

Hello Grassuser,

I am looking for a Grass equivalent to Focalmean(grid, ANNULUS, irad, orad) (info at http://edndoc.esri.com/arcobjects/9.2/NET/shared/geoprocessing/spatial_analyst_tools/focalmean.htm). What I ultimately want to do is calculate Topographic Position Index (info at http://www.jennessent.com/downloads/TPI-poster-TNC_18x22.pdf).

Bob

Bob Moskovitz
Seismic Hazard Zonation Project
California Geological Survey
http://www.conservation.ca.gov/cgs/shzp

CONFIDENTIALITY NOTICE: This communication is intended only for the use of the individual or entity to which it is addressed. This message contains information from the State of California, California Geological Survey, which may be privileged, confidential and exempt from disclosure under applicable law, including the Electronic Communications Privacy Act. If the reader of this communication is not the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this communication is strictly prohibited.

Hi Bob,

not sure if there is any simple way to compute the neighborhood stats via an
annulus shape, but you can use r.neighbors for a rectangular window.

Dylan

On Wednesday 29 August 2007 15:07, Moskovitz, Bob wrote:

Hello Grassuser,

I am looking for a Grass equivalent to Focalmean(grid, ANNULUS, irad, orad)
(info at
http://edndoc.esri.com/arcobjects/9.2/NET/shared/geoprocessing/spatial_anal
yst_tools/focalmean.htm). What I ultimately want to do is calculate
Topographic Position Index (info at
http://www.jennessent.com/downloads/TPI-poster-TNC_18x22.pdf).

Bob

Bob Moskovitz
Seismic Hazard Zonation Project
California Geological Survey
http://www.conservation.ca.gov/cgs/shzp<?xml:namespace prefix = o ns =
"urn:schemas-microsoft-com:office:office" />

CONFIDENTIALITY NOTICE: This communication is intended only for the use of
the individual or entity to which it is addressed. This message contains
information from the State of California, California Geological Survey,
which may be privileged, confidential and exempt from disclosure under
applicable law, including the Electronic Communications Privacy Act. If the
reader of this communication is not the intended recipient, you are hereby
notified that any dissemination, distribution, or copying of this
communication is strictly prohibited.

--
Dylan Beaudette
Soils and Biogeochemistry Graduate Group
University of California at Davis
530.754.7341

On Wed, 2007-08-29 at 15:07 -0700, Moskovitz, Bob wrote:

Hello Grassuser,

I am looking for a Grass equivalent to Focalmean(grid, ANNULUS, irad,
orad) (info at
http://edndoc.esri.com/arcobjects/9.2/NET/shared/geoprocessing/spatial_analyst_tools/focalmean.htm). What I ultimately want to do is calculate Topographic Position Index (info at http://www.jennessent.com/downloads/TPI-poster-TNC_18x22.pdf).

http://grass.itc.it/pipermail/grassuser/2006-June/034457.html

--
Brad Douglas <rez touchofmadness com> KB8UYR/6
Address: 37.493,-121.924 / WGS84 National Map Corps #TNMC-3785

Dylan Beaudette wrote:

not sure if there is any simple way to compute the neighborhood stats via an
annulus shape, but you can use r.neighbors for a rectangular window.

The current CVS version of r.neighbors allows the use of an arbitrary
neighbourhood shape, as well as per-neighbor weights.

--
Glynn Clements <glynn@gclements.plus.com>

Hi Glynn,

I was just looking at the CVS version of r.neighbors but didn't see where I can specify use an arbitrary neighbourhood shape unless it has something to do with the weight=string option. Unfortunately the documentation doesn't mention how to use it.

So, with r.neighbors, how would I annulus shape neighbourhood shape?

Thanks for your help!
Bob

Bob Moskovitz
Seismic Hazard Zonation Project
California Geological Survey
http://gmw.consrv.ca.gov/shmp

CONFIDENTIALITY NOTICE: This communication is intended only for the use of the individual or entity to which it is addressed. This message contains information from the State of California, California Geological Survey, which may be privileged, confidential and exempt from disclosure under applicable law, including the Electronic Communications Privacy Act. If the reader of this communication is not the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this communication is strictly prohibited.

-----Original Message-----
From: Glynn Clements [mailto:glynn@gclements.plus.com]
Sent: Wednesday, August 29, 2007 7:21 PM
To: dylan.beaudette@gmail.com
Cc: grassuser@grass.itc.it; Moskovitz, Bob
Subject: Re: [GRASS-user] Looking for a Grass equivalent to
ESRI'sFocalmean(grid, ANNULUS, irad, orad)

Dylan Beaudette wrote:

not sure if there is any simple way to compute the neighborhood stats via an
annulus shape, but you can use r.neighbors for a rectangular window.

The current CVS version of r.neighbors allows the use of an arbitrary
neighbourhood shape, as well as per-neighbor weights.

--
Glynn Clements <glynn@gclements.plus.com>

On Fri, 2007-08-31 at 17:15 -0700, Moskovitz, Bob wrote:

Hi Glynn,

I was just looking at the CVS version of r.neighbors but didn't see where I can specify use an arbitrary neighbourhood shape unless it has something to do with the weight=string option. Unfortunately the documentation doesn't mention how to use it.

That would be Glynn's documentation skills at work. :slight_smile: I'll try to
correct that.

Yes, you use the 'weight=' option.

So, with r.neighbors, how would I annulus shape neighbourhood shape?

r.neighbors in=input.map out=output.map size=3 weight=weight.file

weights.file should contain something along the lines of:
3 3 3 1 4 8 9 5 3

Thanks for your help!
Bob

Bob Moskovitz
Seismic Hazard Zonation Project
California Geological Survey
http://gmw.consrv.ca.gov/shmp

CONFIDENTIALITY NOTICE: This communication is intended only for the use of the individual or entity to which it is addressed. This message contains information from the State of California, California Geological Survey, which may be privileged, confidential and exempt from disclosure under applicable law, including the Electronic Communications Privacy Act. If the reader of this communication is not the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this communication is strictly prohibited.

BTW, you're sending to a public and well replicated list. There is no
such thing as express or implied confidentiality here. :slight_smile:

--
Brad Douglas <rez touchofmadness com> KB8UYR/6
Address: 37.493,-121.924 / WGS84 National Map Corps #TNMC-3785

Moskovitz, Bob wrote:

I was just looking at the CVS version of r.neighbors but didn't see
where I can specify use an arbitrary neighbourhood shape unless it has
something to do with the weight=string option. Unfortunately the
documentation doesn't mention how to use it.

The argument to the weight= option is the name of a file containing
weights. The file should contain NxN floating-point values (anything
acceptable to scanf's %f conversion).

So, with r.neighbors, how would I annulus shape neighbourhood shape?

Create a weights file with a non-zero value for each cell which should
be part of the neighbourhood, and zero elsewhere. E.g. for size=5:

0 1 1 1 0
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
0 1 1 1 0

The minimum, maximum, diversity and interspersion aggregates don't
care about the actual weight; they simply discard any values with a
zero weight and retain those with a non-zero weight.

For the other aggregates, the way in which the weights affect the
aggregate is fairly intuitive. In particular, an integer weight has
the same effect as repeating the value that may times (integer weights
aren't treated specially; this is just a consequence of how the
weights are handled).

Finally, note that r.neighbors, r.series and r.resamp.stats all use
use the same code for the aggregates (although r.series only uses the
unweighted forms).

--
Glynn Clements <glynn@gclements.plus.com>

On Saturday 01 September 2007, Glynn Clements wrote:

Moskovitz, Bob wrote:
> I was just looking at the CVS version of r.neighbors but didn't see
> where I can specify use an arbitrary neighbourhood shape unless it has
> something to do with the weight=string option. Unfortunately the
> documentation doesn't mention how to use it.

The argument to the weight= option is the name of a file containing
weights. The file should contain NxN floating-point values (anything
acceptable to scanf's %f conversion).

> So, with r.neighbors, how would I annulus shape neighbourhood shape?

Create a weights file with a non-zero value for each cell which should
be part of the neighbourhood, and zero elsewhere. E.g. for size=5:

0 1 1 1 0
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
0 1 1 1 0

This is an excellent update. If this does not make it into the docs soon, let
me know and I can cook up some example HTML + images.

cheers,

Dylan

The minimum, maximum, diversity and interspersion aggregates don't
care about the actual weight; they simply discard any values with a
zero weight and retain those with a non-zero weight.

For the other aggregates, the way in which the weights affect the
aggregate is fairly intuitive. In particular, an integer weight has
the same effect as repeating the value that may times (integer weights
aren't treated specially; this is just a consequence of how the
weights are handled).

Finally, note that r.neighbors, r.series and r.resamp.stats all use
use the same code for the aggregates (although r.series only uses the
unweighted forms).

--
Dylan Beaudette
Soils and Biogeochemistry Graduate Group
University of California at Davis
530.754.7341

Brad Douglas wrote:

> So, with r.neighbors, how would I annulus shape neighbourhood shape?

r.neighbors in=input.map out=output.map size=3 weight=weight.file

weights.file should contain something along the lines of:
3 3 3 1 4 8 9 5 3

Note that spaces and newlines can be used interchangeably, so it's
usually preferable to format the file according to the neighbourhood
shape, i.e.:

3 3 3
1 4 8
9 5 3

--
Glynn Clements <glynn@gclements.plus.com>

Bob Moskovitz wrote:

I was just looking at the CVS version of r.neighbors but didn't see where I
can specify use an arbitrary neighbourhood shape unless it has something to
do with the weight=string option. Unfortunately the documentation doesn't
mention how to use it.

So, with r.neighbors, how would I annulus shape neighbourhood shape?

see also r.mfilter.

Hamish

____________________________________________________________________________________
Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase.
http://farechase.yahoo.com/