trying to export 20 postgreSQL tables to geoJSON using ogr2ogr
ogr2ogr -f "GeoJSON" C:\path\Desktop\geo PG:"host=localhost user=postgres dbname=free password=xx" -t_srs EPSG:4326
getting these 2 errors
ERROR 6: The GeoJSON driver does not overwrite existing files.
ERROR 1: GeoJSON driver failed to create C:\Users\Desktop\geo
I know there is a for loop option but I cannot figure out how to construct it or where to even the cmd location to write it in? in the GDAL folder
For %f in (* PG:"host=localhost user=postgres dbname=free password=xx ACTIVE_SCHEMA=public") do ogr2ogr -f "GEOJSON"% ~ nf.json% f
with my modified script
For %f in ("oak_available_parcels","oak_buffers_union","oak_nonavailable_parcels","oak_park_buffers","oak_park_parcels","oak_reccon_buffers","oak_school_buffers","oak_school_parcels","oak_worship_buffers","oak_worship_parcels","parcels","park_centroid","school_centroid","worship_centroid")
do ogr2ogr -f "GeoJSON" C:\Users\Desktop\geo\%f.json
PG:"host=localhost user=postgres dbname=free password=xx" %f -t_srs EPSG:4326
giving me this error: what is wrong with my cmd statement???
FAILURE: Unable to open datasource `user=postgres' with the following drivers
and postgres is my username for that database
Best Answer
I have tested this my end and it only needs a minor change from the query you added (based on my comment above). If you remove the double quotes from the table names it should work.