[GIS] Getting OGR to work on a Mac

gdalmacogrpostgresql

I downloaded GDAL on my Mac (running Mojave 10.14.1) through Homebrew and I'm having trouble getting OGR to work with Postgresql. When I try the following to create a geojson from gpx files I have, I get the following error:
ERROR 1: Unable to find driver 'PostgreSQL'.

I have tried a bunch of commands to install gdal with postgresql including:

$brew install gdal --with-postgresql

and the command is being recognized and thus ignored. Everytime
gdal 2.3.2, released 2018/09/21 is downloaded.

I've also tried d/ling GDAL Complete from kyngchaos and while it installs, I have no idea where it is on my Mac HD and it's not on the local driver so that Terminal can read it.

Can anyone help?

It seems to be a common problem from what i've researched but there is not good solution to it.

Best Answer

I would recommend doing the install using Anaconda. You can safely do the Conda GDAL install on top of your homebrew GDAL install.

# Create a Conda environment
conda create --name testgdal python=3.7

# Activate the Conda env
source activate testgdal

# Install gdal
conda install gdal

# Install postgis
conda install -c conda-forge postgis

# Check if postgres and postgis are installed
conda list

# Deactivate the Conda env
source deactivate
Related Question