Trouble setting up Postgres PostGIS database with GeoServer Trouble setting up Postgres PostGIS database with GeoServer postgresql postgresql

Trouble setting up Postgres PostGIS database with GeoServer


Check if you have a table called geometry_columns.

If not, then the installation of PostGIS might not have been performed successfully.

Oh, and if you've got multiple databases on your host, make sure that you create your table in a database where you have access to your PostGIS stuff.


I had similar problems when adding PostGIS to an existing PostgreSQL table. Turns out that the 'geometry_columns' and 'spatial_ref_sys' table owner was 'postgres' instead of my user name for the existing postgresql tables (i.e. 'user1').

I logged in as 'postgres' and performed 'ALTER TABLE tablename OWNER TO user1; et voila - problem solved.


I haven't used the installer but you have to enable the geometry types for each database you want to use with PostGIS. Instructions here. Executive summary: enable plpgsql on the database, then pipe it these two files with some variant of these two filepaths:

/opt/local/share/postgresql84/contrib/postgis-2.0/postgis.sql

then:

/opt/local/share/postgresql84/contrib/postgis-1.5/spatial_ref_sys.sql

Those sql files will create 2-3 tables depending on the version of PostGIS, including geometry_columns. That is: psql -d my_geo_db -f /opt/whatever/postgis.sql, then the same with spatial_ref_sys.sql. It is never easy to find postgis.sql or spatial_ref_sys.sql for some reason. No shame in using spotlight.

It is smart to set up a template to avoid having to repeat these steps with later databases, see here. It may also be that the installer has created such a database, try \l from the psql prompt and see if there is something called template_postgis. If so you can create new databases with (as user postgres) createdb -T template_postgis -O your_username new_postgis_db_name