<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hi Daniel,<br>The docs are a good place to start, but here is the simple version, from the command line...<br><br>If you have got Postgres installed OK, you need to create a new database, then install Postgis into it, so I'm assuming you have a working Postgres superuser account you can use. Then:<br><br># create the new, empty database<br>createdb test_gis<br><br># add support for the plpgsql language. Not always needed for v9+ of Postgres, but it # won't hurt anything to try it anyway.<br>createlang test_gis plpgsql<br><br># find where on your system the postgis.sql & spatial_reference_sys.sql files are<br># run these in your new database<br><br>psql -d test_gis -f postgis.sql<br>psql -d test_gis -f spatial_ref_sys.sql<br><br># You now have a working Postgis database.<br># connect to the database<br>psql -d test_gis<br><br># create a simple table
there. QGIS likes integer primary keys, this gives it one<br>create table test_tab (id serial primary key, name varchar(12));<br><br># add a lat/long geometry column to the table<br>select addgeometry('','test_tab','geom',4326,'POINT',2);<br><br># add a couple of points to the table<br>insert into test_tab values (default,'point 1',ST_setsrid(makepoint(179, -45),4326));<br>insert into test_tab values (default,'point 2',ST_setsrid(makepoint(179.2, -45.2),4326));<br><br># see that they exist:<br>select * from test_tab;<br>select id, name, ST_astext(geom) as geom from test_tab;<br><br># exit postgres<br>\q<br><br><br>To open the table & see the points plotted in QGIS you have a bit of configuration to do. By default a Postgres database is installed securely, so external applications & remote computers cannot connect to it.<br><br>The instructions here open the database up to anyone, so it is pretty insecure. If you want to address this, read the
Postgres docs...<br><br>Shut down your Postgres server. How you do this depends on your operating system & version.<br><br>find the file "pg_hba.conf". It contains the access settings.<br>edit this (you may need admin rights) & set all users from all IP addresses for all databases to "trust", as described in the file<br><br>find the file postgresql.conf<br>edit this & set "listen_addresses" to "*" as described in the file ( = all)<br><br>restart the Postgresql service, it will now have an open access configuration, as you just specified.<br><br>You can now fire up QGIS on a local or remote system & connect to the database test_gis on the specified server (if same system as the database, the host is called localhost). QGIS will show you the table test_tab & adding this should show your two points.<br><br>HTH,<br><br> Brent Wood<br><br>--- On <b>Thu, 12/29/11, Daniel Montenegro <i><dmontenegro84@gmail.com></i></b>
wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Daniel Montenegro <dmontenegro84@gmail.com><br>Subject: [postgis-users] How to configure Postgis/Postgresql to use with QGIS<br>To: postgis-users@postgis.refractions.net<br>Date: Thursday, December 29, 2011, 2:37 PM<br><br><div id="yiv1968877626"><div>Hi there!</div><div> </div><div>I've installed Postgis but I'm not being able to create a "spatial" table with a geometry column in Postgresql. Actually, I think I still didn't get all the steps to configure postgis in postgresql.</div>
<div> </div><div>I really need some help!</div><div> </div><div>Thanks a lot,</div><div> </div><div> </div><div>Daniel</div>
</div><br>-----Inline Attachment Follows-----<br><br><div class="plainMail">_______________________________________________<br>postgis-users mailing list<br><a ymailto="mailto:postgis-users@postgis.refractions.net" href="/mc/compose?to=postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br><a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br></div></blockquote></td></tr></table>