Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

share|improve this question
add comment

5 Answers

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

share|improve this answer
2  
a small correction: brew install gdal --with-postgresql –  BenjaminGolder Jan 16 at 22:02
    
Will QGIS still work with the homebrew GDAL? –  Simbamangu 12 hours ago
    
@Simbamangu Sure: homebrew is just a package manager, so the GDAL versions it distributes are the same you can build yourself from source –  Andrea Cremaschi 11 hours ago
    
Have you actuall tested Kyngchaos's QGIS install with homebrew GDAL? His version may not link with homebuilt versions of other libraries! –  Simbamangu 10 hours ago
    
Well it used to work but something seems to be changed with dependencies.. see this Q&A: gis.stackexchange.com/questions/79251/… –  Andrea Cremaschi 8 hours ago
add comment

Save yourself some pain and use the Kyngchaos packaged binaries/frameworks for OSX.GDAL-Complete is the one you are looking for.

Another option is to use HomeBrew.

share|improve this answer
    
AFAIK this is what I used. I didn't install it any other way. –  djq Sep 12 '12 at 21:48
    
Does this file exist: /Library/Frameworks/GDAL.framework/Versions/Current/Libraries/libpq.dylib and what does the 'which ogrinfo' command return from the terminal? –  Ragi Yaser Burhum Sep 12 '12 at 23:05
    
which ogrinfo returns /usr/local/bin/ogrinfo. I installed GDAL and others from KyngChaos before installing QGis. –  djq Sep 12 '12 at 23:24
    
Does the libpq file I mentioned exist in that location? –  Ragi Yaser Burhum Sep 12 '12 at 23:37
1  
If libpq.dylib is not there (the PostgreSQL client library), the OGR library will not load. –  Ragi Yaser Burhum Sep 14 '12 at 22:14
add comment

assuming you've compiled gdal from source, just include --with-pg=/path/to/pg_config when you're configuring gdal.

./configure -with-pg=/path/to/pg_config ...

./make clean

./make

./make install
share|improve this answer
add comment

From reading the ogr2ogr Vector formats doc, it looks like you need to install the PostgreSQL client library (libpq).

This similar question seems to give some insight into resolving a similar issue, just with Python bindings.

share|improve this answer
add comment

I got this same message while on Windows.

It was complaining about the type of quotes (single vs. double) I was using around the connection string. Switching the quotes fixed the issue.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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