Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Using Postgres on a new Mac. I installed Postgres from the dmg file that I downloaded from the Postgres site. I then installed PostGIS using stackbuilder. This all worked flawlessly so far as I can tell.

I have tweaked the pg_hba.conf file to trust connections from local and localhost and created a database "db". Then I tried::

Mac-mini:pg postgres$ bin/createlang plpgsql db
createlang: language "plpgsql" is already installed in database "db"

so it would appear that postgres knows all about postgis.

When I tried:

Mac-mini:pg postgres$ bin/shp2pgsql -c ~rful011/tmp/weed_boundaries weed_plot_boundaries | psql db
Shapefile type: Arc
Postgis type: MULTILINESTRING[2]
NOTICE:  CREATE TABLE will create implicit sequence "weed_plot_boundaries_gid_seq" for serial column "weed_plot_boundaries.gid"
NOTICE:  ALTER TABLE / ADD PRIMARY KEY will create implicit index "weed_plot_boundaries_pkey" for table "weed_plot_boundaries"
ERROR:  function addgeometrycolumn(unknown, unknown, unknown, unknown, unknown, integer) does not exist
LINE 1: SELECT AddGeometryColumn('','weed_plot_boundaries','geom','0...

I must have missed something but what?

Thanks, Russell

share|improve this question
up vote 0 down vote accepted

Creating plpgsql is usually not enough. You also have to create all spatial functions. In Ubuntu, this is how it's done:

createdb postgis_template
createlang plpgsql postgis_template
psql -d postgis_template -f /usr/share/postgresql/8.4/contrib/postgis.sql
psql -d postgis_template -f /usr/share/postgresql/8.4/contrib/spatial_ref_sys.sql
share|improve this answer
ran those commands modulo path names to pg install dir. but still get the same error. I then listed the databases I found I had them duplicated. Not enough space left to post \l output :( – Russell Fulton Feb 11 '13 at 7:49
oops hit return again. \l showed postgis_template postgres template0 template1 template_postgis so I think I already had those created. – Russell Fulton Feb 11 '13 at 8:02
Well, the database "db" you're trying to load into is not PostGIS enabled. Create a test database using postgis_template and try to load into that. – underdark Feb 11 '13 at 9:05
Ah! I get it. postgis_template is just a database name not something magical -- All the docs I have seen use that name so I thought is was part of the incantation. That is what I had failed to understand. Replaced "db" with "postgis_template" and it works. As always, thanks for your help! – Russell Fulton Feb 12 '13 at 6:34

Your Answer


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.