[postgis-users] Intersects/Crosses, Contains/Whthin

cyw at dls.net cyw at dls.net
Thu Oct 9 11:25:48 PDT 2008


Are these functions the same? If so why keeping the duplication?

I have two tables, one is polygons representing counties, and one multiline 
segments representing road segments. The roads are broken into these 
segments whenever there they intersect with other roads, so these segments 
are not very longs.

I want to delete all road segments that are not in a county or cross the 
border of that county, is the sql below right for that purpose?

delete from road where
    NOT Contains((select the_geom from county where 
polygon_nm='A_SPECIFIC_COUNTYNAME'), the_geom)
    AND
    NOT Intersects((select the_geom from county where 
polygon_nm='A_SPECIFIC_COUNTYNAME'), the_geom) ;

The above query for some reason also deletes some road segments in the 
middle of the county polygon.

Thanks,
CYW






More information about the postgis-users mailing list