[GRASSLIST:1174] RE: density surface from points in PostGIS
RafDouglas Candidi Tommasi Crudeli
ct at ns2.ehleng.com
Wed Sep 10 12:29:19 EDT 2003
At 16.00 10/09/2003 +0200, uli wrote:
>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.
sorry, my fault: i meant a "for" cycle or something similar, since you
probably have to repeat a search for every point. The way you do the search
can be directly by querying PostGis or, trivially, scanning the sites file,
calculating the distance and taking note of how many points are nearer than
the given distance.
Take a look at the PostGis manual if you want to go the first way,
otherwise an awk script could do the job.
RafDouglas CTC
>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
More information about the grass-user
mailing list