Based on the Mauricio de Paulo's brand QGIS plugin called WKTRaster, I added raster support to the plugin. Likewise, the layer list widget for PyQGIS was slightly modified in order to get a basic table of contents displaying a number of layer properties.
It is a screenshot (Windows):

As the installation process now includes an images folder, which is actually optional, I think it is recommended to show it again:
PREREQUISITES
Python, PyQt4, PyQGIS and libqt4-sql-psql.
How to install prerequisites in Windows: See this post.
How to install prerequisites in Ubuntu/Linux: For QGIS, see downloads official page. For the other programs use apt-get or Synaptic.
DOWNLOADS
For Ubuntu/Linux download both the postgis_viewer.py and postgis_viewer_imgs.zip files.
For Windows download postgis_viewer.py , postgis_viewer.bat and postgis_viewer_imgs.zip files.
HOW TO USE THE VIEWER FROM A COMMAND LINE
Ubuntu/Linux: Set the execution permission:
$ sudo chmod 755 postgis_viewer.py
Run the Python file setting some parameters:
$ postgis_viewer.py -h localhost -U postgres -W secreto -s public -t pais -d geodb &
If you run the command once more with another table, it will be loaded to the same application:
$ postgis_viewer.py -h localhost -U postgres -W secreto -s public -t rios -d geodb
Windows:
Be sure you have the QGIS libraries enabled and run in a command line:
$ c:\Python25\python.exe postgis_viewer.py -h localhost -U postgres -W secreto -s public -t pais -d geodb &
INSTALLATION AS A pgAdmin PLUGIN (PostgreSQL 8.4)
Ubuntu/Linux:
Copy the postgis_viewer.py file into one of the folders of the environment variable PATH, for instance, /usr/bin/
$ sudo cp postgis_viewer.py /usr/bin/
Set the execution permission:
$ sudo chmod 755 /usr/bin/postgis_viewer.py
Copy the next lines to /usr/share/pgadmin3/plugins.ini (if the file does not exist, you have to create it):
Title=View PostGIS layer
Command=postgis_viewer.py -h $$HOSTNAME -p $$PORT -U $$USERNAME -W $$PASSWORD -d $$DATABASE -s $$SCHEMA -t $$OBJECTNAME
Description=View PostGIS layer
Platform=unix
ServerType=postgresql
Database=Yes
SetPassword=Yes
Extract the postgis_viewer_imgs.zip file into /usr/bin (or the folder where you put postgis_viewer.py) and set execution permission:
sudo unzip postgis_viewer_imgs.zip -d /usr/bin/
sudo chmod 755 /usr/bin/postgis_viewer_imgs/ -R
Windows:
Copy the postgis_viewer.py and postgis_viewer.bat files, and extract the postgis_viewer_imgs.zip file into C:/Program Files/PostgreSQL/8.4/bin/
Edit C:/Program Files/PostgreSQL/8.4/pgAdmin III/plugins.ini adding the following lines:
Title=View PostGIS layer
Command="$$PGBINDIR\postgis_viewer.bat" -h "$$HOSTNAME" -p "$$PORT" -U "$$USERNAME" -W "$$PASSWORD" -d "$$DATABASE" -s "$$SCHEMA" -t "$$OBJECTNAME"
Description=View PostGIS layer
KeyFile=$$PGBINDIR\postgis_viewer.bat
Platform=windows
ServerType=postgresql
Database=Yes
SetPassword=Yes
The postgis_viewer.bat file sets the OSGeo4W environment variables (Qt, Python, QGIS) to allow the execution of postgis_viewer.py The .bat file assumes OSGeo4W is installed in C:/ and PostgreSQL can be found in C:/Program Files/PostgreSQL/8.4/ You should check that file if you get some troubles while running the plugin.
NOTE: The steps are based on PostgreSQL 8.4 and pgAdmin 1.10 has been tested on PostgreSQL <9.1 and pgAdmin <1.13.
KNOWN ISSUES:
- With PyQt4 < 2.6 you will probably get some weird display of the layer properties when dragging a layer. You may check the PyQt4 version from a Python command line this way (If you get a version less than 4.6, you have to upgrade your PyQt4 installation):
>> from PyQt4.QtCore import *
>> VERSION_STR
'4.6'
- If you can not get the icons loaded in the plugin's window, check lines 62 and 65 of the postgis_viewer.py file. There you can edit the path to your postgis_viewer_imgs folder. Note that in Ubuntu/Linux you will probably need the full path whereas in Windows you just need a relative path (according to the tests done).
Finally, another screenshot (Ubuntu/Linux):

--------------------------------------------------------------------------------------------------------
UPDATE (2011/03/09): INSTALL THE PLUGIN ON PostgreSQL 9.0 (pgAdmin 1.12)
In Windwows, users need to be aware of paths for installing the plugin on PostgreSQL 9.0. The following changes need to be done.
(Only WINDOWS)
- The folder to copy postgis_viewer.py, postgis_viewer.bat and extract postgis_viewer_imgs.zip is C:/Program Files/PostgreSQL/9.0/bin, however this may vary according to the installation of PostgreSQL 9.0.
- The plugins.ini file should be edited from C:/Program Files/PostgreSQL/9.0/pgAdmin III/plugins.ini
- The postgis_viewer.bat file should be edited changing the line that executes the postgis_viewer.py file. That line must be: python "C:/Program Files/PostgreSQL/9.0/bin\postgis_viewer.py" %*
-------------------------------------------------------------------------------------------------------
REFERENCES
- Ivan Mincik's PostGIS Viewer: https://github.com/imincik/QgsPostGIS-Viewer
- Send and receive a signal between 2 Qt applications: http://www.qtcentre.org/threads/38453-Send-and-receive-a-signal-between-2-Qt-applications.?p=176716#post176716
- Single Application: http://www.qtcentre.org/wiki/index.php?title=SingleApplication
- Quantum GIS Development Team, 2011. Quantum GIS, Geographic Information System API Documentation. Open Source Geospatial Foundation Project. Electronic document: http://doc.qgis.org/
comments
This is a very good tutorial for the installation of postgis-viewer.
But, the above plug-in requires the installation of OSGeo4W environment.
The files, postgis_viewer.bat and the postgis_viewer.py, contain some variables which correspond to OSGeo4W paths. Because, i have installed seperate all these programs(Postgr eSQL 9.0, PostGIS 1.5.2, Python 2.6, Quantum 1.6) which are contained at OSGeo4W, i must change these paths for the good operation of plug-in.
So, could anyone to show me how to configure these files???
Thanks in advance
in [1] (in Spanish only) I explained how to install and configure PyQGIS without OSGeo4W. It went good until QGIS 1.4. Then the package structure was changed and I've been unable to run it again (as standalone). Therefore, I had to start using OSGeo4W for PyQGIS and I'd recommend you using it. In that case you could still install PostgreSQL and PostGIS without OSGeo4W.
By the way, this is not the final version of this plug-in, have you looked at this (http://geotux.tuxfamily.org/index.php?option=com_myblog&task=view&id=278&Itemid=59〈=en)?
Regards,
Tuxman
-----------------
[1] http://geotux.tuxfamily.org/index.php?option=com_myblog&task=view&id=253&Itemid=59 (http://geotux.tuxfamily.org/index.php?option=com_myblog&task=view&id=253&Itemid=59)
I've trying to set up the tool on Ubuntu 11.10 (Postgres 9.1, PostGIS 1.5.3, pgadmin3 1.14.0-beta1, QGIS & Qt installed and working).
Unfortunately I cannot see the plugin in pgadmin :/
When trying to run it from command line, I get:
"E: Qt or QGIS not installed."
Could you please point me to any solutions to that?
Thanks :]
I haven't tested it on pgAdmin3 >= 1.13, anyway I would recommend you following these new and simplified steps:
http://geotux.tuxfamily.org/index.php/en/geo-blogs/item/278-constructor-de-consultas-sql-para-el-visor-de-capas-postgis-para-pgadmin-3
If the problem still persists, please go to the postgis_viewer.py file and try to run in a python console lines 42 to 50, one by one. This way you can discover if there is any PyQt4 module you are missing.
Tuxman
Ubuntu 10.10, pgadmin3 1.10.5-1.
have you already tried the new version?:
http://geotux.tuxfamily.org/index.php/en/geo-blogs/item/278-constructor-de-consultas-sql-para-el-visor-de-capas-postgis-para-pgadmin-3
It has a simplified installation.
Tuxman
Yes, this was my first choice, but a more complex thought could solve the problem. Anyway, I threw out the installation that had postgis_viewer_ imgs and tried again with your suggestion. It did not work. The problem continues.
thanks for your answer,
saludo,
Koblitz
I began everything again and, it's work. Indeed I changed directly in the plugin.ini file. Put in there all my information, include the geometry column. The post_viewer open now through the icon 'plugin' from pgadmin. I can't see nothing in there, but I believe is a problem to know consult. Let's see. I made the right thing?
it can be because the directory "/usr/bin" is not registered as PostgreSQL bin path. Please go to pgAdmin3, File-->Options-->General tab-->PG bin path and check the folder. If it's in fact different, extract the postgis_viewer.zip file right there.
If that's not the problem, please take the plugins.ini content from the newest post of this series [1], as you see, they are a bit different. Just copy the content as it is, you don't need to edit anything to adjust it for your data or so.
If you still have troubles with this installation send me your plugins.ini file, or think of giving me access to your machine for a while, so I can take a closer look at this.
Regards,
Tuxman
--------------
[1] http://geotux.tuxfamily.org/index.php/en/geo-blogs/item/278-constructor-de-consultas-sql-para-el-visor-de-capas-postgis-para-pgadmin-3
I write plugin.ini exactly like recommend here. Ok it's work. thanks!
i have installed python 2.7.8 x64 bit, pyqt4 for python 2.7 and all.....Now i want to install postgis viewer in my database.
please explain in english soon.
RSS feed for comments to this post