# [GRASSLIST:1168] RE: density surface from points in PostGIS

uli uli.mueller at gmx.ch
Wed Sep 10 10:00:35 EDT 2003

```RafDouglas

Thank you for this pretty cool and fast method for counting points! However
it counts points per quadratic cell of a regular mesh. What I need is a
count of randomly placed points within a given radius around each grid cell
(e.g. grid spacing 100 m, count within radius of 5000 m aroudn each cell >
every point can show up in the count of several cells).
Or do you mean this by "a simple cycle". If so, I am too slow to get it.

Uli

>-----Original Message-----
>From: RafDouglas Candidi Tommasi Crudeli [mailto:ct at ehleng.com]
>Sent: Mittwoch, 10. September 2003 11:26
>To: uli
>Cc: GRASSLIST at baylor.edu
>Subject: Re: [GRASSLIST:1156] density surface from points in PostGIS
>
>
>At 11.00 10/09/2003 +0200, uli wrote:
>>Hi list
>>
>>New to GRASS but with a pressing geostatistical task I hope for your help:
>>
>>I have a PostGIS table with some hundreds of points (x,y, no other
>>attributes). I need to calculate the "density" of points within a given
>>radius for each cell of a grid. "Density" here simply means the number of
>>points, nothing like kernel or interpolations.
>>The output can be in GRASS format or PostGIS or anything else.
>>
>>What is the fastset way to do this?
>>Do I need GRASS, or are you aware of any other more compact tools?
>>Or do you have an idea for a fast SQL-statement doing the job?
>>
>>Thank you, Uli
>
>not a full answer, but:
>for finding the count of points on a regular mesh:
>
>cat \$LOCATION/sites_list/sites.s | awk -F"|" '{
>x=int(\$1/100)
>y=int(\$2/100)
>print x,y}' |sort -nk1,2 | uniq -c | awk '{print \$1"|"\$2"|#"\$3}'>count.s
>
>where 100 are the x-step and y-step of the mesh
>
>you could then use s.to.rast and visualize the count number of points for
>each cell. The density is: count/(x_step*y_step)
>
>
>For what you need, I would approach a simple cycle (if you don't have
>millions of points, it won't take much time...)
>
>bye,
>
>         RafDouglas CTC
>
>
>___________________________________________
>Dott. Ing. RafDouglas Candidi Tommasi Crudeli
>ct at ehleng com
>___________________________________________
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: =?US-ASCII?Q?Uli_Muller.12657DEFANGED-vcf?=
Type: application/octet-stream
Size: 664 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/grass-user/attachments/20030910/b2bbd345/US-ASCIIQUli_Muller.obj
```