<br><br>
<div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Susana Iraiis Delgado Rodriguez</b> <span dir="ltr"><<a href="mailto:susana.delgado_s@utzmg.edu.mx">susana.delgado_s@utzmg.edu.mx</a>></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 ("capas1.txt","w+")<br> print 'Ingresa el nombre del shape que deseas leer'<br> b = raw_input()<br> print '\n'<br> dbf = Dbf(b+".dbf",new=False)<br>
<br> for rec in dbf:<br> for fldName in dbf.fieldNames:<br> if fldName == 'LAYER':<br> l=()<br> l=rec[fldName]<br> a.write(l)<br> a.write("\n") <br> #dbf.close()<br> a.close()<br>
<br>##Get a txt with the the attribute of the dbf layers <br> a = open ("capas1.txt","r")<br> catalogo = open ("unico1.txt","w")<br> unique = set(a.read().split("\n"))<br>
catalogo.write("".join([line + "\n" for line in unique]))<br> catalogo.close()<br> a.close()<br> <br>##Execute ogr2ogr<br> for line in open("unico1.txt", "r"):<br> p = subprocess.Popen(['C:/Archivos de programa/FWTools2.4.7/bin/ogr2ogr', line.replace("\n", "") +'.shp', '-where', "\"LAYER='"+ line.replace("\n", "") +"'\"" , b+'.shp'])<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't show anything. I attached a piece of the input shape I used. </div>
</div><br>