I have a table in PostgreSQL(postgis). This table has latitude and longitude values in it.
Now I want to plot these point in qgis. The only thing I could get done was connecting to the database from QGIS.

Could anyone please let me know on how to go about it.Thank You.

Here is the screenshot below

Below is the connection error I get while connection to the database from QGIS

I am not sure what you are asking, is the problem that you cannot view your points in qgis? are your lats and lons separate fields in your table, or have you inserted them as a geometry?
–
atlefrenApr 20 '12 at 12:15

4 Answers
4

Your problem is that you do not have a geometry column. You could either find out how to get QGIS to display lon/lat fields, ad GIS-Jonathan mentioned was possible, or you could create a geometry-column (assuming that all your lon/lat fields are non-empty:

Thanks. But due to lack of db knowledge I get an error now. ERROR: function addgeometrycolumn(unknown, unknown, unknown, integer, unknown, integer) does not exist LINE 1: SELECT AddGeometryColumn ('public','growth','the_geom',4326,... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. ********** Error **********
–
SenthilApr 20 '12 at 13:30

It seems like you haven't installed PostGIS or "spatially enabled" your database, the lack of any functions and the geometry_columns table are clues. Could you try running: SELECT postgis_lib_version()
–
atlefrenApr 20 '12 at 13:38

The first syntax works fine now and I get a new error for the second one :) ERROR: parse error - invalid geometry HINT: "SRID =4326;POINT(" <-- parse error at position 17 within geometry ********** Error ********** ERROR: parse error - invalid geometry SQL state: XX000
–
SenthilApr 20 '12 at 13:58

Per @atlefren comment - if you haven't loaded the data correctly (it will need to be a geometry type to do this, though there are ways to do it if its just lat/lon fields) the first part of that tutorial does cover loading the data.
–
GIS-JonathanApr 20 '12 at 12:19

Yes this is what I was looking for. But the table which was created just has a few fields with no lat longs. Now when I check the option for list geometryless tables it doesnt display this table .
–
SenthilApr 20 '12 at 12:24

I can't tell on there, but are your latitude and longitude stored as strings or numbers? I imagine QGIS won't like them if they're not a suitable number type which may be your problem.
–
GIS-JonathanApr 20 '12 at 13:01

If your table only has lat and long data, you will need to create a geometry column out of them. I recommend using the qgis plugin "Fast SQL Layer" and then (assuming your table structure has the columns id as integer, lat as float, lng as float and the data is in WGS84) get a new layer using