Getting PostGIS 1.5.3 working with Postgresql90 (Macports)

Started by René Fournierover 14 years ago6 messagesgeneral
Jump to latest
#1René Fournier
renefournier@gmail.com

What I want to do is import some shape files, using the shp2pgsql loader. However, I need a database first, and I've read I need to make it spatially aware, which means creating it from the "template_postgis". All the docs I read indicate that template_postgis should be present after installing PostGIS. But… When I try to create a database from that template, I'm told it's missing.

createdb -T template_postgis demo -U postgres

createdb: database creation failed: ERROR: template database "template_postgis" does not exist

I've found tutorials on creating your own postgis template ( http://www.lincolnritter.com/blog/2007/12/04/installing-postgresql-postgis-and-more-on-os-x-leopard/ ), but I'd like to use what appears to be the standard one. Actually, I wondered if PostGIS was even running (Macports indicates it's installed and active):

sudo port installed | grep postg

postgis @1.5.3_0+postgresql90 (active)
postgresql90 @9.0.5_0 (active)
postgresql90-server @9.0.5_0 (active)
postgresql_select @0.1_0 (active)

I tried importing a SHP file anyway:

shp2pgsql -c -D -s 4269 -i -I demo.shp | psql -d demo -U postgres

Shapefile type: Arc
Postgis type: MULTILINESTRING[2]
SET
SET
BEGIN
NOTICE: CREATE TABLE will create implicit sequence "nrn_ab_8_0_roadseg_gid_seq" for serial column "nrn_ab_8_0_roadseg.gid"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "nrn_ab_8_0_roadseg_pkey" for table "nrn_ab_8_0_roadseg"
CREATE TABLE
ERROR: function addgeometrycolumn(unknown, unknown, unknown, unknown, unknown, integer) does not exist
LINE 1: SELECT AddGeometryColumn('','nrn_ab_8_0_roadseg','the_geom',...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
ERROR: current transaction is aborted, commands ignored until end of transaction block

Appears as though Postgis isn't even 'there'.
(Sorry, I'm a MySQL guy. I'm just trying to get started without asking too many dumb questions.)

Best regards,
René Fournier

#2Scott Ribe
scott_ribe@elevated-dev.com
In reply to: René Fournier (#1)
Re: Getting PostGIS 1.5.3 working with Postgresql90 (Macports)

On Oct 7, 2011, at 5:38 PM, René Fournier wrote:

(Sorry, I'm a MySQL guy. I'm just trying to get started without asking too many dumb questions.)

Frankly, I think you'd be better served by deleting the entirety of the macports stuff and installing postgresql from source the normal UNIX way: ./configure, make, sudo make install... That's the way I do it, and it works fine on OS X.

--
Scott Ribe
scott_ribe@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice

#3René Fournier
renefournier@gmail.com
In reply to: Scott Ribe (#2)
Re: Getting PostGIS 1.5.3 working with Postgresql90 (Macports)

Well, I would -- and I used to build a lot of stuff from source -- except there are a ton of other packages that Macports makes dead-simple to install.

Plus, I find Macports makes it easy to automate a server build in one script. The problem as I see it isn't Macports but my unfamiliarity with Postgresql.

On 2011-10-07, at 6:21 PM, Scott Ribe wrote:

On Oct 7, 2011, at 5:38 PM, René Fournier wrote:

(Sorry, I'm a MySQL guy. I'm just trying to get started without asking too many dumb questions.)

Frankly, I think you'd be better served by deleting the entirety of the macports stuff and installing postgresql from source the normal UNIX way: ./configure, make, sudo make install... That's the way I do it, and it works fine on OS X.

--
Scott Ribe
scott_ribe@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice

Best regards,
René Fournier

#4Scott Ribe
scott_ribe@elevated-dev.com
In reply to: René Fournier (#3)
Re: Getting PostGIS 1.5.3 working with Postgresql90 (Macports)

On Oct 7, 2011, at 7:39 PM, René Fournier wrote:

Plus, I find Macports makes it easy to automate a server build in one script. The problem as I see it isn't Macports but my unfamiliarity with Postgresql.

I think it's both ;-) I tried macports for a couple of things and gave up on it. It works for getting dependencies for certain things. Then one day it doesn't work because you're trying a combination that wasn't accounted for, and you now have no idea how all those things you previously installed are configured...

But if you can find the pg log, it will usually pretty explicitly tell you why the server is quitting on launch. So you might just need to read those wrapper scripts to see how exactly they invoke postgres.

--
Scott Ribe
scott_ribe@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice

#5René Fournier
renefournier@gmail.com
In reply to: Scott Ribe (#4)
Re: Getting PostGIS 1.5.3 working with Postgresql90 (Macports)

On 2011-10-07, at 7:58 PM, Scott Ribe wrote:

On Oct 7, 2011, at 7:39 PM, René Fournier wrote:

Plus, I find Macports makes it easy to automate a server build in one script. The problem as I see it isn't Macports but my unfamiliarity with Postgresql.

I think it's both ;-) I tried macports for a couple of things and gave up on it. It works for getting dependencies for certain things. Then one day it doesn't work because you're trying a combination that wasn't accounted for, and you now have no idea how all those things you previously installed are configured…

Sorry, I neglected to say, I have Postgresql running. The problem was the initial means of running it. Unlike the Macports documentation,

sudo /opt/local/etc/LaunchDaemons/org.macports.postgresql90-server/postgresql90-server.wrapper start

…did the trick. My current problem is figuring out how to get PostGIS integrated/working and/or the template_postgis thing working (since it appears I need that to create spatial databases).

But if you can find the pg log, it will usually pretty explicitly tell you why the server is quitting on launch. So you might just need to read those wrapper scripts to see how exactly they invoke postgres.

--
Scott Ribe
scott_ribe@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice

Best regards,
René Fournier

#6Craig Ringer
craig@2ndquadrant.com
In reply to: René Fournier (#5)
Re: Getting PostGIS 1.5.3 working with Postgresql90 (Macports)

On 10/08/2011 10:35 AM, Ren� Fournier wrote:

On 2011-10-07, at 7:58 PM, Scott Ribe wrote:

On Oct 7, 2011, at 7:39 PM, Ren� Fournier wrote:

Plus, I find Macports makes it easy to automate a server build in
one script. The problem as I see it isn't Macports but my
unfamiliarity with Postgresql.

I think it's both ;-) I tried macports for a couple of things and
gave up on it. It works for getting dependencies for certain things.
Then one day it doesn't work because you're trying a combination that
wasn't accounted for, and you now have no idea how all those things
you previously installed are configured�

Sorry, I neglected to say, I have Postgresql running. The problem was
the initial means of running it. Unlike the Macports documentation,

sudo
/opt/local/etc/LaunchDaemons/org.macports.postgresql90-server/postgresql90-server.wrapper
start

�did the trick. My current problem is figuring out how to get PostGIS
integrated/working and/or the template_postgis thing working (since it
appears I need that to create spatial databases).

template_postgis is just the "empty" database template PostGIS creates
when it is first installed and configured. It's just like template1, but
has the PostGIS support functions and schema already installed. It
should be created as part of the regular install and configuration
process for PostGIS, AFAIK.

I don't use PostGIS or MacOS, so I can't help much with that side...

--
Craig Ringer