1

I am, trying to export GeoJSON from postgis. I am using the following code which is working local machine but when I am trying to use this in a server the following error is occuring

CODE:

ogr2ogr -progress -f GeoJSON landuse_gen0.geojson -t_srs EPSG:4326 "PG:host=localhost port=5432 dbname=database user=usernbame password=Password" -sql "SELECT way, way_area AS area, COALESCE(landuse, leisure, 'natural', highway, amenity, tourism) AS type FROM planet_osm_polygon WHERE way_area > 100000 ORDER BY way_area DESC"

ERROR:

FAILURE:
Unable to open datasource `PG:host=localhost port=5432 dbname=database user=usernbame password=Password' with the following drivers.
  -> `PCIDSK'
  -> `PDF'
  -> `ESRI Shapefile'
  -> `MapInfo File'
  -> `UK .NTF'
  -> `OGR_SDTS'
  -> `S57'
  -> `DGN'
  -> `OGR_VRT'
  -> `REC'
  -> `Memory'
  -> `BNA'
  -> `CSV'
  -> `GML'
  -> `GPX'
  -> `KML'
  -> `GeoJSON'
  -> `ESRIJSON'
  -> `TopoJSON'
  -> `OGR_GMT'
  -> `WAsP'
  -> `OpenFileGDB'
  -> `XPlane'
  -> `DXF'
  -> `CAD'
  -> `Geoconcept'
  -> `GeoRSS'
  -> `GPSTrackMaker'
  -> `PGDUMP'
  -> `GPSBabel'
  -> `SUA'
  -> `OpenAir'
  -> `OGR_PDS'
  -> `HTF'
  -> `AeronavFAA'
  -> `EDIGEO'
  -> `SVG'
  -> `Idrisi'
  -> `ARCGEN'
  -> `SEGUKOOA'
  -> `SEGY'
  -> `ODS'
  -> `XLSX'
  -> `SXF'
  -> `Selafin'
  -> `JML'
  -> `VDV'
  -> `MVT'
  -> `TIGER'
  -> `AVCBin'
  -> `AVCE00'
2
  • 2
    Can you connect to the database using some other means, such as psql? Is is possible that you are trying to connect on an Internet socket, while the DB server is only listening on a Unix domain socket? Jun 22, 2019 at 18:00
  • ST_AsGeoJSON works as well postgis.net/docs/ST_AsGeoJSON.html
    – Mapperz
    Jun 22, 2019 at 22:32

1 Answer 1

2

It looks like the version of ogr2ogr you have on server was built without PostgreSQL support, or the postgres driver is not installed. Note that in the list of drivers there is no PostgreSQL, ogr2ogr just tries all existing drivers and none of them understands the connection string - this is what the error message means.

ogrinfo might provide better diagnostics.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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