I have written several complicated python scripts that end up using ogr2ogr to load or translate data. I have been converting these scripts to standalone exe files meaning the team do not require Python installed and some of the additional modules I use in other parts of the code.
However, I always end up using a subprocess and calling shp2pgsql.exe or ogr2ogr.exe, like this
load_ogr = """ogr2ogr --config PG_USE_COPY YES -a_srs "EPSG:27700" -skipfailures -gt 65536 -f PGDump /vsistdout/ %s -lco GEOMETRY_NAME=geom -lco SCHEMA=data -lco CREATE_SCHEMA=OFF -lco CREATE_TABLE=OFF -lco SPATIAL_INDEX=OFF -nln %s | psql -d multi -U postgres -f -"""%(shapefilename,tablename) run = subprocess.Popen(load_ogr, shell=True) run.communicate()
Which iterates through a file list and loads the data in.
However, I can not bundle this code effectively into a standalone exe because it calls ogr2ogr found via it being installed on the host machine and found in the PATH
How can I change this to use the python ogr bindings (ogr.py)?
I have found very little code examples or tutorials on how to use the python ogr version, so any pointers to good resources would be very useful too