[postgis-users] Cut a hole in a line layer (opposite of a cookie cutter)??

Martin Davis mbdavis at refractions.net
Mon Jun 4 08:53:13 PDT 2007


You could form the union of the "mask" polygons and then use the 
difference function to obtain the portion of each line which lies 
outside them.

This assumes of course that your polygon layer isn't too big. If it is 
very big, you may need to use the approach of taking the difference of 
every line from the union of the polys which interact with that line. 
This might be slow, however.

Matt Doughty wrote:
>
> Hi,
>
> I’ve got a new problem… how in PostGIS could I perform the opposite of 
> a cookie cutting operation? Better said, use a polygon layer to cut a 
> hole in a line layer thereby keeping the lines from outside the 
> polygons but not those inside. I’ve been trying with a cooking cutting 
> script (see below) by placing NOT before the operators but without 
> much luck.
>
> SELECT
>
> cookie.gid,
>
> INTERSECTION(cookie.the_geom, cutter.the_geom) AS the_geom
>
> INTO
>
> curvas_isla_not_02
>
> FROM
>
> roads AS cookie,
>
> urban_areas AS cutter
>
> WHERE
>
> cookie.the_geom && cutter.the_geom
>
> AND
>
> INTERSECTS(cookie.the_geom, cutter.the_geom)
>
> I’ve also tried to use the results from the cookie cutter script to 
> select those lines that don’t coincide with those from the cookie (see 
> below), but also without any luck.
>
> SELECT
>
> roads.gid,
>
> roads.the_geom
>
> INTO
>
> roads_not_urban
>
> FROM
>
> roads,
>
> roads_urban
>
> WHERE
>
> roads.the_geom && roads_urban.the_geom
>
> AND
>
> NOT INTERSECTS(roads.the_geom, roads_urban.the_geom);
>
> If anybody’s got any tips on how to do this, or advice on where I’m 
> going wrong….!
>
> Many thanks,
>
> Matt
>
> Matt Doughty
>
> 	
>
> GEOGRAMA S.L.
>
> Tel.: +34 945 13 13 72 652 77 14 15
>
> Fax: +34 945 23 03 40
>
> www.geograma.com
>
> 	
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>   

-- 
Martin Davis
Senior Technical Architect
Refractions Research, Inc.
(250) 383-3022




More information about the postgis-users mailing list