For reference: http://postgis.net/install
The most reliable way to get PostGIS on OSX is to download and install Postgres.app. Great for development and testing. Do not mix with other installations. Select the extension when prompted.
You just need to add the extensions, Homebrew users can just run brew install postgis
-
Drop into your database
psql oneblock_development
-
Run the following commands to add the extensions.
-- Enable PostGIS (includes raster)
$ CREATE EXTENSION postgis;
If you get:
ERROR: 58P01: could not open extension control file "/usr/local/Cellar/postgresql/9.3.4/share/postgresql/extension/postgis.control": No such file or directory
you probably don’t have the extension installed correctly.
-- Enable Topology
$ CREATE EXTENSION postgis_topology;
-- fuzzy matching needed for Tiger
$ CREATE EXTENSION fuzzystrmatch;
-- Enable US Tiger Geocoder
$ CREATE EXTENSION postgis_tiger_geocoder;
Confirm that it worked:
$ SELECT POSTGIS_FULL_VERSION();
You should see a message including postgis_full_version
followed by a version number and some other info.
For anyone having the issue above, you need to install postgis using Homebrew and need to make sure the version of postgis that you install is compatible with the version of postgresql that you have already installed.
In my case I had postgresql version 9.5.5 so I needed to install postgis version 2.2.2. If you just run
brew install postgis
, the current version at the time of writing is 2.3.3, which is only compatible with postgresql version 9.6 and above.I followed the instructions at http://stackoverflow.com/questions/3987683/homebrew-install-specific-version-of-formula/17757092#17757092 for how to install an older version of postgis with Homebrew. To save you some time, if you're looking to install version 2.2.2 (specifically version 2.2.2_3 which seems to be the most recent) you can use the following command: