[postgis-users] How do you do neighborhood functions?

Wood Brent pcreso at pcreso.com
Wed Apr 14 09:27:56 PDT 2004


--- collin <collin at socrates.Berkeley.EDU> wrote:
> I probably should qualify my question. The datasets I will use this on 
> will ulitmately be larger than 2GB in size, thus, I can't use Arc/Info, 
> ArcGIS, MapInfo, or Fragstats for that matter, due to 32bit limits.  
> This is why I am trying to implement processing inside a database.

A possible inelegant solution,

export the unique ids for your points to a file (or pipe them into the while
read)

then

while read <unique ID> do
  #select avge for all points within 10m
  (psql -d <db> -c "...")
  & write to table
done < <file of point id's

I'm not sure if the select avge can be done in one step, or would require more,
but I can see a few ways of doing what I think you want to do with
Postgres/PostGIS. Not quickly on a large no of points though.

Like select having distance, or pre-processing so each point has an appropriate
buffer circle created via an insert trigger so for each point you can then
select points within the buffer circle. (I assume the central point should be
included in the result?)


I don't know if this helps, but a slightly different approach is available with
the blockmean command of GMT. It averages values in a grid cell (block), cell
specs defined on the command line. If gridding with an appropriate cell size
would be adequate for your needs, this might work.

>From the online docs at gmt.soest.hawaii.edu:

       blockmean  reads  arbitrarily  located  (x,y,z)  triples [or optionally
       weighted quadruples (x,y,z,w)] from standard input  [or  xyz[w]file(s)]
       and  writes to standard output a mean position and value for every non-
       empty block in a grid region  

-C     Use the center of the block as the output location [Default uses
       the mean location].


Brent Wood



More information about the postgis-users mailing list