[postgis-users] Viewing the PostGIS in Action examples in QGIS

James David Smith james.david.smith at gmail.com
Wed Feb 13 02:58:55 PST 2013


Hi Charles,

As Atle says, you won't be able to view that point or the polygon in
QGIS or anything like that. The query that you have ran is creating
the point as an example. It creates it out of thin air for want of a
better example. It isn't stored anywhere for you to be able to access
from other software.

If you want to be able to look at it in QGIS you would need to store
the results of the query in a new table. You would use the 'SELECT
INTO' function to do it which is documented here:

http://www.postgresql.org/docs/9.1/static/sql-selectinto.html

Using your examples:

SELECT ST_Point(1, 2) AS MyFirstPoint INTO new_table;

OR

SELECT ST_GeomFromText('LINESTRING(52 218, 139 82, 262 207, 245 261, 207 267,
153 207, 125 235, 90 270, 55 244, 51 219, 52 218)') AS HeartLine INTO
new_table2;

No when you open QGIS and connect to your PostgreSQL database you
should see the two tables above in the list. Add them to your view in
QGIS and the lines and point should appear on your screen.

Cheers

James




On 13 February 2013 07:24, Atle Frenvik Sveen <atle.sveen at bouvet.no> wrote:
> Well, it seems as though you've misunderstood a bit. Your query executed
> fine, but it was a SELECT query, so all it did was running the ST_Point()
> function and displaying the result. Nothing stored in no tables, so i'd be
> very supried if you found it again somewhere.
>
> If I rememeber correctly the book covers creating spatial columns, loading
> and storing data, so I suggest you gather some patience and continue the
> book :)
>
> Good luck!
>
> -atle
>
> --
>  Atle Frenvik Sveen / 54°23'55"S 3°24'5"E
> Konsulent
> Bouvet Norge AS, Kjøpmannsgata 35, NO-7011 Trondheim
> Tlf +47 75 53 70 00 Mobil +47 45 27 86 89
> http://www.bouvet.no   atle.sveen at bouvet.no
> ________________________________
> From: postgis-users-bounces at lists.osgeo.org
> [postgis-users-bounces at lists.osgeo.org] on behalf of Charles Sprowal
> [uchihabarles at gmail.com]
> Sent: Wednesday, February 13, 2013 7:50 AM
> To: postgis-users at lists.osgeo.org
> Subject: [postgis-users] Viewing the PostGIS in Action examples in QGIS
>
> Hello,
>
>      I have just started reading through the book PostGIS In Action in an
> attempt to learn Postgis, but have encountered a problem right at the start.
> After creating a spatially enabled database, the text asks me to run the
> following sql:
>
> SELECT ST_Point(1, 2) AS MyFirstPoint;
>
> The query ran successfully. If I understand correctly, that statement
> creates a point in the db. After installing QuantumGIS and accessing the
> database through it, I expected to be able to view the point, but I could
> not. I had a similar problem with another query in the same chapter that's
> supposed to generate a heart-shaped polygon:
>
> SELECT ST_GeomFromText('LINESTRING(52 218, 139 82, 262 207, 245 261, 207
> 267,
> 153 207, 125 235, 90 270, 55 244, 51 219, 52 218)') AS HeartLine;
>
> When I connect to the database through QGIS, I get the following log
> message: "Database connection was successful, but the accessible tables
> could not be determined." The only table that is listed as having geometry
> (table "raster_columns" under schema "public") does not seem to contain the
> point. I cannot even select the table to add a layer from it.
>
> I've followed the instructions in chapter 12.3 for QGIS use and remain at a
> loss. Any idea where I'm going wrong?
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>


More information about the postgis-users mailing list