[GIS] How to update ogr2ogr to include the PostgreSQL driver

ogr2ogrpostgispostgresqlshapefile

I'm trying to use ogr2ogr to upload a shapefile to a remote PostGres installation. When I ran this command:

celenius:~ celenius$ ogr2ogr -f PostgreSQL PG:"host=255.34.00.00 user=postgres dbname=mydb password=***" Dropbox/data/roads.shp;

I got the following error message:

Unable to find driver `PostgreSQL'.
The following drivers are available:
  -> `ESRI Shapefile'
  -> `MapInfo File'
  -> `UK .NTF'
 ...
  -> `SVG'
  -> `CouchDB'
  -> `Idrisi'
  -> `ARCGEN'
  -> `SEGUKOOA'
  -> `SEGY'

(I omitted some of the drivers as they are not relevant). Is there a way that I can update ogr2ogr to include PostgreSQL? I'm using a Mac with OS 10.7.4

Best Answer

Using Homebrew you should:

brew install gdal --with-postgresql

or with older versions of gdal:

brew install gdal --with-postgres

if you have already installed gdal with brew before but without postgresql support, just

brew uninstall gdal