6

After installing postgresql with postgis under windows xp I have 3 databases:

postgis
postgres
template_postgis

now I try to create a new spatially enabled database in pgAdminIII: I select template_postgis in the pgAdminIII object browser and via rightclick in the context-menu I select new object ->new database. when I try to use this database in QGIS with the spit-plugin I get the following error message:

the chosen database does not have PostGIS installed, but this is required for storage of spatial data.

How do I create a working spatial postgis database? please help a rookie

thanks

Kurt

3
  • selecting template_postgis and then clicking into the PgAdmin III toolbar to "create a new object of the same type as the selected object" (= blue arrow -icon) also doesnt work
    – Kurt
    Commented Mar 2, 2012 at 21:41
  • I did follow Stéphane's tip:Right-click on any database, choose New Database, fill Name and Owner and, under Template, choose template_postgis. Let me know if that works? But when I Right-click on any database, choose New Database, fill Name and Owner and, under Template, choose template_postgis......, I got an error told me that this template, say template_postgis_20, is being used by other users, so I can't create an new database, how can I do?
    – Heinz
    Commented Apr 1, 2013 at 10:16
  • I had the same error after initially installing PostGIS/PosgreSQL with PgAdmin. After rebooting, I didn't get the error message and the new postgis database was created
    – user12711
    Commented Apr 22, 2013 at 3:05

2 Answers 2

8

Right-click on any database, choose New Database, fill Name and Owner and, under Template, choose template_postgis. Let me know if that works?

2
  • Stéphane, it works - thank you very much for your support. choosing the template_postgis did the trick!!
    – Kurt
    Commented Mar 2, 2012 at 22:40
  • Good, by the way, to check that your DB is PostGIS-enabled, verify that you have the tables geometry_columns and spatial_ref_sys in your schema public. And also the view geography_columns (as of PostGIS 1.5, I believe) Commented Mar 5, 2012 at 10:20
2

Within PgAdmin make a new database. Then click on the database, click on the SQL icon enter image description here

In the SQL paste the following line:

CREATE EXTENSION postgis;

Then press the run icon. That should create the postgis functionality in that database.


This approach works for PostGIS 2.0, but not apparently for PostGIS 1.5 ( I tested both on Win 7).

2
  • clenius, on my system this prodcues an error: no such file or directory SQL State 58P01
    – Kurt
    Commented Mar 2, 2012 at 22:45
  • clenius, thank you for your support! yes i am using Postgis 1.5 ps. after further investigations I found an other way to make a nonspatial database spatial is to run the deliver postgis.sql. this should work also on non-windos-systems
    – Kurt
    Commented Mar 3, 2012 at 23:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.