geospatial team at nomad labs
Some might find this useful for creating PostGIS databases without having to be postgresql superusers. The idea is to create a template_postgis database, install plpgsql and postgis into it, and then use this database as a template when creating new PostGIS databases.
$ psql template1 \c template1 CREATE DATABASE template_postgis WITH template = template1; -- set the 'datistemplate' record in the 'pg_database' table for -- 'template_postgis' to TRUE indicating its a template UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template_postgis'; \c template_postgis CREATE LANGUAGE plpgsql ; \i /usr/share/postgresql/contrib/lwpostgis.sql; \i /usr/share/postgresql/contrib/spatial_ref_sys.sql; -- in a production environment you may want to -- give role based permissions, but granting all for now GRANT ALL ON geometry_columns TO PUBLIC; GRANT ALL ON spatial_ref_sys TO PUBLIC; -- vacuum freeze: it will guarantee that all rows in the database are -- "frozen" and will not be subject to transaction ID wraparound -- problems. VACUUM FREEZE;
Now non-superuser’s can create postgis db’s using template_postgis:
createdb -h host-name my_gisdb -W -T template_postgis
GeoLabs is the Spatial team at Nomad Labs. We love all things spatial and particularly like the idea of spatial analysis on the geoweb. We also tend to use a lot of open source GIS in our work. Yey! to the open source. Other than that we love dynamic languages, open RESTful API's and beautiful code and thoughtfully designed software. All things that we try to adhere to in our work.
chetantiwari.com » Blog Archive » Allow non superuser accounts to create spatial databases
June 29th, 2007 at 2:36 am
[...] A nice tutorial can be found here: http://geospatial.nomad-labs.com/2006/12/24/postgis-template-database/ [...]
Install PostGIS : £ri©
August 2nd, 2008 at 7:46 pm
[...] user bisa membuat database menggunakan template ini. Cara ini diperoleh dari milis postgis oleh GeoLabs $pgsql~> psql template1 c template1 CREATE DATABASE template_postgis WITH template = template1; [...]