2

I want to convert spatial data from postgres to some basic formats (shp, geopackage, csv, xlsx, gml... ) using python gdal functionality. I read the answer to this question: Using ogr2ogr to convert GML to shapefile in Python?

I downloaded ogr2ogr.py and tried to convert data from postgres to some formats but I get an error saying:

KML driver failed to create /home/.../out.kml

This is the method I am using:

 ogr2ogr.main(["", "-f", "KML", "/home/.../out.kml",
              "PG:dbname='dbname' host='host' port=5432 user='username' password='password'",
              "-sql", "SELECT column1, column2 FROM schema.table"])
DrJacoby
  • 781
  • 3
  • 15

1 Answers1

1

I'm not sure about the select column part but this should produce the entire table in kml:

ogr2ogr.main(["", "-f", "KML", "/home/.../out.kml",
              "PG:dbname='dbname' host='host' port=5432 user='username' password='password'","table"])
artwork21
  • 35,114
  • 8
  • 66
  • 134