<br><br>
<div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Susana Iraiis Delgado Rodriguez</b> <span dir="ltr">&lt;<a href="mailto:susana.delgado_s@utzmg.edu.mx">susana.delgado_s@utzmg.edu.mx</a>&gt;</span><br>
Date: 2010/10/19<br>Subject: Command ogr2ogr makes copies instead of shapes<br>To: <a href="mailto:fwtools@lists.maptools.org">fwtools@lists.maptools.org</a><br><br><br>
<div>Hello list!</div>
<div> </div>
<div>I developed a python module that executes an ogr2ogr command for make shapes from one input shape, but when I run the script instead of making the output shapes creates copies from the input shape. Here is my code:</div>

<div> </div>
<div>import shlex, subprocess, sys, fileinput<br>from dbf import *<br>from string import strip</div>
<div>def process():<br>##Read dbf<br> a = open (&quot;capas1.txt&quot;,&quot;w+&quot;)<br> print &#39;Ingresa el nombre del shape que deseas leer&#39;<br> b = raw_input()<br> print &#39;\n&#39;<br> dbf = Dbf(b+&quot;.dbf&quot;,new=False)<br>
   <br> for rec in dbf:<br>            for fldName in dbf.fieldNames:<br>    if fldName == &#39;LAYER&#39;:<br>     l=()<br>     l=rec[fldName]<br>     a.write(l)<br>     a.write(&quot;\n&quot;) <br> #dbf.close()<br> a.close()<br>
 <br>##Get a txt with the the attribute of the dbf layers <br> a = open (&quot;capas1.txt&quot;,&quot;r&quot;)<br> catalogo = open (&quot;unico1.txt&quot;,&quot;w&quot;)<br> unique = set(a.read().split(&quot;\n&quot;))<br>
 catalogo.write(&quot;&quot;.join([line + &quot;\n&quot; for line in unique]))<br> catalogo.close()<br> a.close()<br> <br>##Execute ogr2ogr<br> for line in open(&quot;unico1.txt&quot;, &quot;r&quot;):<br>    p = subprocess.Popen([&#39;C:/Archivos de programa/FWTools2.4.7/bin/ogr2ogr&#39;, line.replace(&quot;\n&quot;, &quot;&quot;) +&#39;.shp&#39;, &#39;-where&#39;, &quot;\&quot;LAYER=&#39;&quot;+ line.replace(&quot;\n&quot;, &quot;&quot;) +&quot;&#39;\&quot;&quot; , b+&#39;.shp&#39;])<br>
  process()</div>
<div> </div>
<div>As I mentioned before it works but not the way it should work, it generates the shapes sometimes as copies, sometimes they are different but if you want to see them in other software for example Kosmo, it doesn&#39;t show anything. I attached a piece of the input shape I used. </div>
</div><br>