[FWTools] Fwd: Command ogr2ogr makes copies instead of shapes

Susana Iraiis Delgado Rodriguez susana.delgado_s at utzmg.edu.mx
Tue Oct 19 10:00:58 EST 2010


---------- Forwarded message ----------
From: Susana Iraiis Delgado Rodriguez <susana.delgado_s at utzmg.edu.mx>
Date: 2010/10/19
Subject: Command ogr2ogr makes copies instead of shapes
To: fwtools at lists.maptools.org


Hello list!

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:

import shlex, subprocess, sys, fileinput
from dbf import *
from string import strip
def process():
##Read dbf
 a = open ("capas1.txt","w+")
 print 'Ingresa el nombre del shape que deseas leer'
 b = raw_input()
 print '\n'
 dbf = Dbf(b+".dbf",new=False)

 for rec in dbf:
            for fldName in dbf.fieldNames:
    if fldName == 'LAYER':
     l=()
     l=rec[fldName]
     a.write(l)
     a.write("\n")
 #dbf.close()
 a.close()

##Get a txt with the the attribute of the dbf layers
 a = open ("capas1.txt","r")
 catalogo = open ("unico1.txt","w")
 unique = set(a.read().split("\n"))
 catalogo.write("".join([line + "\n" for line in unique]))
 catalogo.close()
 a.close()

##Execute ogr2ogr
 for line in open("unico1.txt", "r"):
    p = subprocess.Popen(['C:/Archivos de
programa/FWTools2.4.7/bin/ogr2ogr', line.replace("\n", "") +'.shp',
'-where', "\"LAYER='"+ line.replace("\n", "") +"'\"" , b+'.shp'])
  process()

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/fwtools/attachments/20101019/5debf313/attachment-0001.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tapalpa_plani_line_recorte.shp
Type: application/octet-stream
Size: 25148 bytes
Desc: not available
Url : http://lists.maptools.org/pipermail/fwtools/attachments/20101019/5debf313/attachment-0001.obj 


More information about the FWTools mailing list