Wrestling with Ogr2Ogr again here. I have managed to use it to import a geojson file into a PostGis database, can query and manipulate the database layer. However, when I try and export the database table to a new file I get the message: "Unable to open datasource 'myexport.geojson' with the following drivers"

GeoJson is in the list of drivers, and the layer is in PostGis.

.\ogr2ogr -f "GeoJSON" "PG:host=**** port=**** dbname=**** user=**** password=****" "C:\Temp\output.geojson"

  • 2
    You should only ask one question. /u/bugmenot123 answered your initial question, you should accept it as correct and ask another question. – HeikkiVesanto Mar 27 '18 at 13:27
  • I've rolled back the question to the state in which it was answered. Once a question has been answered, if you have another question, then ask a new question for it. If the original provides any useful background then you can always include a link to it. – PolyGeo Mar 28 '18 at 8:25

ogr2ogr expects the destination datasource before the source in the invocation:

Usage: ogr2ogr (...)
               dst_datasource_name src_datasource_name

Your line is in the wrong order.

  • Thanks that fixed it. Now I'm running into problems getting just a specific table set of data. Will add update. – Tristan Rhodes Mar 27 '18 at 11:55
  • 1
    That is a different problem, please open a new question for that. – bugmenot123 Mar 27 '18 at 13:48
  • What's wrong with "select * from with_id"? Is the table listed if you run ogrinfo "PG:host=**** port=**** dbname=**** user=**** password=****" ? – user30184 Mar 27 '18 at 19:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.