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.

Using Postgres 9.2.3.1 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]
SET
SET
BEGIN
NOTICE:  CREATE TABLE will create implicit sequence "weed_plot_boundaries_gid_seq" for serial column "weed_plot_boundaries.gid"
CREATE TABLE
NOTICE:  ALTER TABLE / ADD PRIMARY KEY will create implicit index "weed_plot_boundaries_pkey" for table "weed_plot_boundaries"
ALTER TABLE
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

1 Answer 1

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
1  
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

 
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.