Create a new clip polygon which is the differenec between the blue one and the outer rectangle. then aply that one as you did the blue one.<br><br><div class="gmail_quote">2009/9/30 James G Wilkinson <span dir="ltr"><<a href="mailto:jgw@alpinegeophysics.com">jgw@alpinegeophysics.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">









<div link="blue" vlink="purple" lang="EN-US">

<div>

<p><span style="font-size: 10pt; font-family: "Courier New";">Folks,</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">I
am having a problem determining the best way to clip out and disgrad a set of
linestrings.  Here is my setup:</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">*****************</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">*****************</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">itn=#
select postgis_full_version();</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">                                              
postgis_full_version                                              
</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">------------------------------------------------------------------------------------------------------------------</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> POSTGIS="1.3.2"
GEOS="3.0.0-CAPI-1.4.1" PROJ="Rel. 4.4.9, 29 Oct 2004"
USE_STATS (procs from 1.1.2 need upgrade)</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">(1
row)</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">itn=#
select version();</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">                                                
version                                         
        </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">----------------------------------------------------------------------------------------------------------</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> PostgreSQL
8.1.3 on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.0.0 20050519
(Red Hat 4.0.0-8)</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">(1
row)</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">*****************</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">*****************</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">My
linestring network has the following attributes (and a picture for
visualization):</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">*****************</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">*****************</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">itn=#
\d itn.scaglinks</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">   
                                              Table
"itn.links"</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">        
Column        
|       Type      
|                                 
Modifiers                                  
</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">------------------------+------------------+-------------------------------------------------------------------------</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> record_id_alternate   
| integer          | not null
default nextval('itn.scaglinks_record_id_alternate_seq3'::regclass)</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> a_node                
| integer          | </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> b_node                
| integer          | </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> dist                  
| integer          | </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> taz_id                
| integer          | </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> .<clip></span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> .</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> .<clip></span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> the_geom              
| geometry         | </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">Indexes:</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">   
"idx_scaglinks_00" btree (a_node)</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">   
"idx_scaglinks_01" btree (b_node)</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">   
"idx_scaglinks_02" btree (a_node, b_node)</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">   
"idx_scaglinks_03" btree (link_id)</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">   
"pkgis_scaglinks" gist (the_geom)</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">Check
constraints:</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">   
"enforce_dims_the_geom" CHECK (ndims(the_geom) = 2)</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">   
"enforce_geotype_the_geom" CHECK (geometrytype(the_geom) =
'MULTILINESTRING'::text OR the_geom IS NULL)</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">   
"enforce_srid_the_geom" CHECK (srid(the_geom) = 26911)</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"><img src="cid:image002.png@01CA41C0.724B6370" alt="scaglinks.GIF" width="588" height="362"></span><span style="font-size: 10pt; font-family: "Courier New";"></span></p>


<p><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">*****************</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">*****************</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">My
clipping polygon has the following attributes (and a picture for
visualization):</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">*****************</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">*****************</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">itn=#
\d itn.itn_clip_polygon_1</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> Table
"itn.itn_clip_polygon_1"</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> 
Column  |   Type   | Modifiers </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">----------+----------+-----------</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> cyid    
| integer  | </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> the_geom
| geometry | </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">Indexes:</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">   
"pkgis_itn_clip_polygon_1" gist (the_geom)</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"><img src="cid:image004.png@01CA41C0.724B6370" alt="scaglinks_clip_polygon.GIF" width="578" height="357"></span><span style="font-size: 10pt; font-family: "Courier New";"></span></p>


<p><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">*****************</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">*****************</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">When
I run the following command to clip the scaglinks linestrings, the </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">results
are what I would expect (again, a picture for visualization):</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">*****************</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">*****************</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">itn=#
create table clipped as select intersection(a.the_geom,b.the_geom) as </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">new_geom,
length(a.the_geom) as original_link_length, a.* from scaglinks a, </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">itn_clip_polygon_1
b where intersects(a.the_geom,b.the_geom);</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">SELECT</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">itn=#
create index pkgis_clipped on clipped using gist(new_geom);</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">CREATE
INDEX</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">itn=#
\d itn.clipped</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">                 
Table "itn.clipped"</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">        
Column        
|       Type      
| Modifiers </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">------------------------+------------------+-----------</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> new_geom              
| geometry         | </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> original_link_length  
| double precision | </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> record_id_alternate   
| integer          | </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> a_node                
| integer          | </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> b_node                
| integer          | </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> dist                  
| integer          | </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> taz_id                
| integer          | </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> .<clip></span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> .</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> .<clip></span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> the_geom              
| geometry         | </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">Indexes:</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">   
"pkgis_clipped" gist (new_geom)</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"><img src="cid:image009.png@01CA41C0.724B6370" alt="scaglinks_clipped.GIF" width="539" height="331"></span><span style="font-size: 10pt; font-family: "Courier New";"></span></p>


<p><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">*****************</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">*****************</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">What
I am really after are the links that fall outside the clipping</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">polygon. 
So I attempted the following query:</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">*****************</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">*****************</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">itn=#
create table clipped2 as SELECT a.*, difference(a.the_geom,b.new_geom) as
new_geom from scaglinks a, clipped b;</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">********
after 12 hours, the query throws the following error ********</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">ERROR:
could not extend relation 1663/164540/180960: No space left on device</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">HINT:
Check free disk space</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">*****************</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">*****************</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">The
scaglinks network consists of 108,000 links and the clipped network</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">consists
of 6,200 links.  I have approximately 1.5 TB of free disk so I</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">do
not believe that disk space should be a problem.</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">*****************</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">*****************</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">Again,
what I had hoped is that the query to create clipped2 would return</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">a table
that results in the following graphic:</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"><img src="cid:image010.png@01CA41C0.724B6370" alt="but_want_this.GIF" width="560" height="346"></span><span style="font-size: 10pt; font-family: "Courier New";"></span></p>


<p><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">*****************</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">*****************</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">Can
you offer any help in the query that will result in a table that</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">looks
something like the last graphic?</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">Best
Regards,</span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>

<p><span style="font-size: 10pt; font-family: "Courier New";">Jim</span></p>

</div>

</div>


<br>_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>
<a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Brian Modra   Land line: +27 23 5411 462<br>Mobile: +27 79 69 77 082<br>5 Jan Louw Str, Prince Albert, 6930<br>Postal: P.O. Box 2, Prince Albert 6930<br>South Africa<br>
<a href="http://www.zwartberg.com/">http://www.zwartberg.com/</a><br>