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

Paul Ramsey pramsey at refractions.net
Wed Apr 14 07:37:52 PDT 2004


There is no one-statement solution to the "find me the nearest Y to X"  
problem. If you know a distance D for which you always have at least  
one feature within range, you can do something like (this is pseudo  
code, you will have to replace X and Y and D with geometries/numbers):

SELECT *,distance(X,Y) AS distance FROM thextable WHERE x &&  
expand(y,d) ORDER BY
distance LIMIT 1;

Repeat the above for every Y of interest.

On Tuesday, April 13, 2004, at 11:04 PM, collin 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.
>
> -- Collin
>
> Craig Miller wrote:
>
>> I would export the data out of PostGIS and use Fragstats.
>>
>> --Craig
>>
>>
>> -----Original Message-----
>> From: collin [mailto:collin at socrates.Berkeley.EDU]
>> Sent: Tuesday, April 13, 2004 9:48 AM
>> To: postgis
>> Subject: [postgis-users] How do you do neighborhood functions?
>>
>>
>> Greetings folks,
>>
>> 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
>
      Paul Ramsey
      Refractions Research
      Email: pramsey at refractions.net
      Phone: (250) 885-0632




More information about the postgis-users mailing list