[postgis-users] Re: touches() not returning correct values, maybe?

Paul Ramsey pramsey at refractions.net
Tue Jan 2 21:42:19 PST 2007


Your working query can probably be speeded up a little by avoiding  
the geometric Equals and replacing it with an equality test on your  
gid (since you are self-joining the table).

Basically, intersects() pulls all the features with an interaction  
(edge or overlap) and that includes the feature interacting with  
itself. so:

select
   t1.gid as gid,
   t2.gid as adj_gid
from
   stands t1,
   stands t2
where
   t1.boundary && t2.boundary and
   t1.gid <> t2.gid and
   intersects( t1.boundary, t2.boundary )
order by
   t1.gid,
   t2.gid;


On 2-Jan-07, at 2:17 PM, Paul Ramsey wrote:

> Touches() is only true if the exteriors interact and the interiors  
> do not. If your adjacent polygons overlap slightly, then they do  
> not just touch.
>
> P.
>
> Jeff D. Hamann wrote:
>> This seems to remedy this situation.
>> select
>>   t1.gid as gid,
>>   t2.gid as adj_gid
>>  from
>>   stands t1,
>>   stands t2
>>  where
>>   intersects( t1.boundary, t2.boundary ) AND
>>    t1.boundary && t2.boundary and
>>   Equals( t1.boundary, t2.boundary ) is FALSE
>> order by
>> 	t1.gid,
>> 	t2.gid;
>> So why is this different than
>> select
>>   t1.gid as gid,
>>   t2.gid as adj_gid
>>  from
>>   stands t1,
>>   stands t2
>>  where
>>   touches( t1.boundary, t2.boundary ) AND
>>    t1.boundary && t2.boundary and
>> order by
>> 	t1.gid,
>> 	t2.gid;
>> Jeff.
>
> _______________________________________________
> 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