In ArcGIS, I want to use a Python script (and a standard ArcGIS script tool UI) to call functionality from FWTools.
How would I make the call to FWTools? I tried using os.system(C:\WINDOWS\system32\cmd.exe /K "C:\Program Files\FWTools2.4.7\setfw.bat") which is what the windows shortcut calls, but that is not it. It seems I am probably missing something rather simple, but I can't figure out how to make the right call through python to get FWTools & ogr2ogr operating on the string I pass.
My UI looks like this:
and the pseudo-code behind it is something like:
'ogr2ogr -f "' + outformat + '" "' + outfile + '" "' + infile + '" ' + ogrvars
Answer
It turns out it was just a silly mistake on my part and forgetting that paths in Python need to be either "\" or "/". The code itself was very simple:
'"C:\\WINDOWS\\system32\\cmd.exe /C" "C:\\Program Files\\FWTools2.4.7\\bin\\ogr2ogr.exe" ' + ogrstring
I have posted the toolbox and python code at:
No comments:
Post a Comment