[FWTools] Executing ogr2ogr from independent python module

Susana Iraiis Delgado Rodriguez susana.delgado_s at utzmg.edu.mx
Fri Oct 1 08:28:33 EST 2010


Hello:

I'm new in the use of FWTools enviroment. I'm developing a python module
that executes an ogr2ogr command. This module will ask the user to enter
some parameters such as map names, layer names, etc. I already make my code
to execute setfw and ogr2ogr, but when I enter the argument that points to
tha original file, it shows me an error. I copied and pasted the code and
the error. Hope you can help me.

from dbf import *
from osgeo import ogr
import os
import sys
def call():
      print "Ingresa el nombre para el nuevo mapa"
      arg1 = "R1G-GEODESIA2.shp"
      print arg1
      print "Ingresa la condicion"
      arg2 = "LAYER = 'R1G-GEODESIA'"
      print arg2
      print "Ingresa el nombre del mapa original"
      arg3 = 'tapalpa_05_plani_point.shp'
      print arg3
      os.system('"C:/Archivos de programa/FWTools2.4.7/setfw"')
      os.chdir('C:\Python26')
      os.system('"C:/Archivos de programa/FWTools2.4.7/bin/ogr2ogr.exe"'+" "
+"arg1" +" "+ "-where" +" "+ "arg2" +" " +"arg3"+"")
call()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "fw.py", line 20, in <module>
    call()
  File "fw.py", line 18, in call
    os.chrdir('C:\Python26')
AttributeError: 'module' object has no attribute 'chrdir'
>>> import fw
Ingresa el nombre para el nuevo mapa
R1G-GEODESIA2.shp
Ingresa la condicion
LAYER = 'R1G-GEODESIA'
Ingresa el nombre del mapa original
tapalpa_05_plani_point.shp
FAILURE:
Unable to open datasource `arg3' with the following drivers.
  -> ESRI Shapefile
  -> MapInfo File
  -> UK .NTF
  -> SDTS
  -> TIGER
  -> S57
  -> DGN
  -> VRT
  -> REC
  -> Memory
  -> BNA
  -> CSV
  -> NAS
  -> GML
  -> GPX
  -> KML
  -> GeoJSON
  -> Interlis 1
  -> Interlis 2
  -> GMT
  -> SQLite
  -> ODBC
  -> PGeo
  -> OGDI
  -> PostgreSQL
  -> MySQL
  -> XPlane
  -> AVCBin
  -> AVCE00
  -> DXF
  -> Geoconcept
  -> GeoRSS
  -> GPSTrackMaker
  -> VFK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/fwtools/attachments/20101001/f04f197f/attachment.htm 


More information about the FWTools mailing list