I'm trying to write some script using the ogr2ogr
function in python:
convertstring = 'ogr2ogr -f r"GeoJSON" r"Output.GeoJson" -select * -where "layer = building" r"' + filepath+'"'
os.system(convertstring)
but I keep getting this error:
FAILURE: Unable to open datasource `myApp.py' with the following drivers.
This is a little odd - myApp.py is the app that I'm running so there is no need to open it, and I'm not asking it to open it. Any help really appreciated.
os.system()
uses a shell to execute the command, so that asterisk gets expanded to all the filenames in the current working directory.Unrelated to that, I strongly doubt that all those
r"
thingies do what you want them to do (whatever that is!).You might be better off using
subprocess.run()
.