I am trying to export a PostGIS table to GeoJSON using ogr2ogr.
The following works perfectly when I launch it in Windows command :
ogr2ogr -f "GeoJSON" F:\output.json PG:"host=**** port=**** dbname=**** user=**** password=****" --optfile F:\query.sql`
However, when I save this command as a .bat file and then try to launch it in Windows command, I receive an error :
FAILURE: Unable to open datasource `PG:host=**** port=**** dbname=**** user=**** password=****' with the following drivers.
Is there any way I can make this command work as a .bat file?
ogrinfo PG:"host=**** port=**** dbname=**** user=**** password=****" --debug on
as the first line into your batch file. Perhaps it prints some useful info for you. Do you have any odd characters that may have a special meaning for the batch file in your connection parameters?ogrinfo PG:"host=**** port=**** dbname=**** user=**** password=****" --debug on
to the batch file and I got theFAILURE: Unable to open datasource
message. However, I also wrote this same command directly in Windows command and it correctly listed all tables in my database. I have not changed the connection parameters, but I am using a French computer (could language parameters possibly change how ogr2ogr deals with a batch command rather than a direct command?)