[postgis-users] distance from one class to another

Stephen Woodbridge woodbri at swoodbridge.com
Wed Jul 13 09:03:06 PDT 2005


Try something like this:

select distance((select the_geom from tableA a, tableB b where 
a.comtrs=b.comtrs and site_name='APPLE'), (select the_geom from tableA 
a, tableB b where a.comtrs=b.comtrs and site_name='PEAR'));

-Steve W.
  http://imaptools.com/

Brent Pedersen wrote:
> hi, searched the archives and read the manual but cant figure out how to do 
> this.
> 
> for a particular tableB.gid where site_name = 'APPLE' i want to find the 
> distance to the closest tableB.gid where site_name = 'PEAR'.  
> 
> 'the_geom' is in tableA. 'comtrs' links the 2 tables.
> 
> thanks for any pointers or references. 
> 
> 
> i have tableA:
>   Column  |       Type        | Modifiers
> ----------+-------------------+-----------
>  gid      | integer           |
>  ddlat    | numeric           |
>  ddlong   | numeric           |
>  comtrs   | character varying |
>  the_geom | geometry          | not null
> 
> and tableB:
>  comtrs                  | character varying(11) |
>  site_name               | character varying(70) |
>  product_name            | character varying(80) |
>  pounds_product_applied  | real                  |
>  chemical_name           | character varying(80) |
>  pounds_chemical_applied | real                  |
>  amount_treated          | real                  |
> 
> 
> _______________________________________________
> 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