[postgis-users] Question about Crosses(geometry, geometry)

Mark Cave-Ayland mark.cave-ayland at ilande.co.uk
Fri Jun 8 03:47:09 PDT 2007


On Fri, 2007-06-08 at 12:00 +0200, Matt Doughty wrote:
> Hi List,
> 
>  
> 
> I’ve a question about the CROSSES (geometry, geometry) function. I’d
> like to use it to select lines from a table that do not cross, or
> intersect, some polygons in a separate table. 
> 
>  
> 
> The following script lets me select the lines that cross the polygons:
> 
>  
> 
> SELECT 
> 
>             lines.*
> 
> FROM 
> 
>             lines, 
> 
>             polygons
> 
> WHERE 
> 
>             CROSSES(lines.the_geom, polygons.the_geom)
> 
>  
> 
> Now I’d like to place a ‘NOT’ before the function CROSSES (-> NOT
> CROSSES(lines.the_geom, polygons.the_geom), rather naively it seems,
> as doing that returns me a table with the same geometry as the
> original layer, but with 30 times more rows (an increase of 400 to
> 12,000 records). In other words, it hasn’t ‘selected’ and lines out of
> the layer, merely repeated the table geometry 30 times.


Interesting. Does something like this work?

SELECT lines.* FROM lines EXCEPT SELECT lines.* FROM lines, polygons
WHERE crosses(lines.the_geom, polygons.the_geom)


Kind regards,

Mark.

-- 
ILande - Open Source Consultancy
http://www.ilande.co.uk





More information about the postgis-users mailing list