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

Jan Hartmann j.l.h.hartmann at uva.nl
Wed Apr 14 06:15:59 PDT 2004


You can do this with a grouping function on a complex join on the same 
table, something like:

select avg(height)
     from mytable as t1,
          (select x(the_geom) as x,y(the_geom) as y
                  from mytable
          ) as t2
      where point_inside_circle(t1.the_geom,t2.x,t2.y,10)
      group by t1.the_geom
;

Jan

collin wrote:

>> Question:  I would like to find the average height (z2) of all the
>> points within 10 meters of every point.  Any ideas on how to do this?
>> I have point data from lidar (snippet below).  I made point geometry
>> from the raw data.
>>           time      |          x2         |          y2       |
>> z2   |  int2 |                      geom2
>>
>> -------------+-----------------+----------------+---------+------+---------- 
>>
>> ---------------------------------------
>> 161626.12404 | 10568414.29 |      4247026 | 388.2   |   75 |
>> SRID=32610;POINT(10568414.29 4247026 388.2)
>> 161626.12407 | 10568414.31 |      4247026 | 388.26 |   74 |
>> SRID=32610;POINT(10568414.31 4247026 388.26)
>> 161626.1241   | 10568414.33 | 4247026.01 | 388.33 |   75 |
>> SRID=32610;POINT(10568414.33 4247026.01 388.33)
>>
>> I tried
>>    UPDATE napatest SET z2avg10 = avg(z2)
>>    WHERE point_inside_circle(geom_point_first, xf, yf, 10);
>> but this only updated a single row.  z2avg10 is a new field I had added.
>>
>> Is there a standard method for performing neighborhood functions? i.e.
>> any set of statistics for each and every row about their neighboring 
>> points.
>>
>> thanks in advance,
>>
>> Collin
>> GIS informatics researcher, UC Berkeley
>>
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>>
>>
>>
>>
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>>
>>
>>  
>>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
> 



More information about the postgis-users mailing list