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

Fri Jun 3 15:29:58 EDT 2005

```Chuck,

Does this assume you only have one raster map cell shape? What if there
are multiples, which is what I think Jason has? I think, then, you would
get a single center of mass for the cluster of separate cells.

Tom

Charles Ehlschlaeger wrote:

> 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
>

--
National Weather Service
Ohio River Forecast Center
1901 South State Route 134
Wilmington, OH 45177