Seems like the difference of the streets with the intersection of the forests and the streets should do that.
st_difference(streets,st_intersection(streets,forests)) Eric -----Original Message----- From: postgis-users-boun...@postgis.refractions.net [mailto:postgis-users-boun...@postgis.refractions.net]On Behalf Of Stefan Keller Sent: Saturday, January 29, 2011 9:04 PM To: PostGIS Users Discussion Subject: [postgis-users] How to calculate the symmetric difference of linestrings and polygons (i.e. linestrings which do not intersect polygons) Hi, Given streets linestrings and forest polygons, think of all streets segments which are *not* inside forest areas. How can I calculate all segments from linestrings which do not intersect polygons? Any ideas? - S. Attempt 1: ST_SymDifference sounds good! But even this equivalent produces nonsense: # SELECT ST_AsText( ST_CollectionExtract(ST_Difference(ST_Union(ls.way,po.way), ST_Intersection(ls.way,po.way)),2) ) FROM linestring ls, polygon po Attempt 2: # SELECT ST_AsText(ST_Intersection(ls.way, po.way)) FROM linestring ls, polygon po gives me all streets *inside* forests. But I'd like get the "remainder" in between... Attempt 3: # SELECT ST_AsText(ST_Difference(ls.way, po.way)) FROM linestring ls, polygon po gives me two displaced lines for each street (because the resultse contains the difference between one line and one polygon), Thesse two could be intersected - but ST_Intersection of two overlapping lines (with same nodes except end nodes) does'nt seem to work. Attempt 4: In a very desperate idea, I calculcated the extent of both tables in order generate a huge boundary polygon with has as many wholes as there are polygons. Then I could do an ST_Intersect of this big swiss cheese polygon with the lines - but no luck. Attempt 5: I finally tried to dump all points from Attempt 2 (intersection) to get hold of the boarder points where lines and polygons cross. But when tried to split a line at a point and to sort out all lines outside polygons things got again complicated.. _______________________________________________ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users _______________________________________________ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users