# [GRASSLIST:7007] Re: calculating center of intensity

Charles Ehlschlaeger CR-Ehlschlaeger2 at wiu.edu
Fri Jun 3 15:06:16 EDT 2005

```I don't have GRASS working on my computer to check this out, however,
here is a procedure to calculating the center of a shape:

Assume you have a raster map "shape" where the value of 0 is at all
places w/out the shape and a positive value where the shape is located at.

1) Find the total volume of the shape w/:

1a) r.mapcalc command function:
one = "1"

1b) r.volume d=shape clump=one

(There should be a better way of doing this.)

2) Calculate volumeOnAxis of shape in North-South dimension with the
r.mapcalc command:

NSvolumeOn = shape * y()

3) Calculate massOnAxis of shape in East-West dimension with the
r.mapcalc command:

EWvolumeOn = shape * x()

4) Find the total volume of NSvolumeOn with:

r.volume d= NSvolumeOn clump=one

5) Find the total volume of EWvolumeOn with:

r.volume d= NSvolumeOn clump=one

6) The coordinates of the center will be
east = total volume of EWvolumeOn / volume of shape
north = total volume of NSvolumeOn / volume of shape

A little csh and awk programming could replicate Idrisi's center program.

<INSERT DISCLAIMERS ABOUT USING AT OWN RISK...>

sincerely, chuck

Markus Neteler wrote:

>On Thu, Jun 02, 2005 at 03:42:36PM -0400, Jason Horn wrote:
>
>
>>Does anyone know of a way to calculate the center of a shape in a
>>raster file based on shape and pixel values?  For example, imagine a
>>NEXRAD RADAR image showing a storm cloud.  Could GRASS be used to
>>calculate the center of the cloud?  I'm not having any luck finding a
>>grass raster function to do this.
>>
>>
>
>I did a quick google search for
>or
>which a couple of hits. Some programming might
>be needed. I don't know if these algorithms are freely
>available.
>
>Markus
>
>
>

--
Chuck Ehlschlaeger, Associate Professor & GIS Center Director
Department  of  Geography,      Western  Illinois  University
306C Tillman Hall,  1 University Circle,  Macomb,  IL   61455
cre111 at wiu.edu,    phone: 309-298-1841,     fax: 309-298-3003

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-user/attachments/20050603/43574890/attachment.html
```