You are here:GeoTux»Geo-Blogs»Geographic databases»Improvements in the PostGIS Viewer for pgAdmin


Invitados: 82
Usuarios registrados: 3271
Usuarios en línea:
Registrados hoy:



Blogs and News:
Recibe las actualizaciones en Geo-Noticias y Geo-Blogs

Get them by e-mail
Recibir Geo-Noticias y Geo-Blogs por e-mail

¿What is this about?

Sunday, 06 March 2011 06:00

Improvements in the PostGIS Viewer for pgAdmin

Written by  German Carrillo
Rate this item
(5 votes)
Due to some suggestions from Ivan Mincik and Iván Lizarazo, I have been adding a couple of functionalities to the postgis viewer plugin for pgAdmin. Now, it has raster support (PostGIS-WKTRaster) and a layer list widget for displaying layer properties. Additionally, some minor bugs have been fixed: antialiasing and map units detection.


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): 

Postgis viewer plugin for pgAdmin (Windows)


As the installation process now includes an images folder, which is actually optional, I think it is recommended to show it again:



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.




For Ubuntu/Linux download both the and files.

For Windows download , postgis_viewer.bat and files.




Ubuntu/Linux: Set the execution permission:

 $ sudo chmod 755 

Run the Python file setting some parameters:
 $ -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:
 $ -h localhost -U postgres -W secreto -s public -t rios -d geodb  



Be sure you have the QGIS libraries enabled and run in a command line:

 $ c:\Python25\python.exe -h localhost -U postgres -W secreto -s public -t pais -d geodb &  




Copy the file into one of the folders of the environment variable PATH, for instance, /usr/bin/

 $ sudo cp /usr/bin/  

Set the execution permission:
 $ sudo chmod 755 /usr/bin/  

Copy the next lines to /usr/share/pgadmin3/plugins.ini (if the file does not exist, you have to create it):
Description=View PostGIS layer

Extract the file into /usr/bin (or the folder where you put and set execution permission:

  sudo unzip -d /usr/bin/ 
sudo chmod 755 /usr/bin/postgis_viewer_imgs/ -R



Copy the and postgis_viewer.bat files, and extract the 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

The postgis_viewer.bat file sets the OSGeo4W environment variables (Qt, Python, QGIS) to allow the execution of 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.




  • 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 *

  • If you can not get the icons loaded in the plugin's window, check lines 62 and 65 of the 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):

Postgis viewer plugin for pgAdmin (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.



  • The folder to copy, postgis_viewer.bat and extract 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 file. That line must be: python "C:/Program Files/PostgreSQL/9.0/bin\" %*







Last modified on Wednesday, 12 October 2011 18:48


0 # alelentz 2011-06-17 10:09
Hi folks

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, 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
Reply | Reply with quote | Quote
0 # Re:tuxman 2011-06-17 10:36
Hi alelentz,

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 (〈=en)?



[1] (
Reply | Reply with quote | Quote
0 # Installation problems on Ubuntu 11.10radek 2011-10-27 02:25
Thanks a lot for tutorial!

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 :]
Reply | Reply with quote | Quote
0 # Re:tuxman 2011-10-27 09:01
Hi radek,

I haven't tested it on pgAdmin3 >= 1.13, anyway I would recommend you following these new and simplified steps:

If the problem still persists, please go to the 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.

Reply | Reply with quote | Quote
0 # actually seekoblitz 2011-10-27 05:14
Congratulations on your post. I followed your step by step tutorial. the plugin name appears on the icon of pgadmin, but fails to appear for the fact I view the maps. There are two folders postgis_viewer. One in / usr / bin and another in / usr / bin / postgis_viewer. I have already put in both, and nothing worked. Do you have any suggestion about how I can dyscovery my mistake?
Ubuntu 10.10, pgadmin3 1.10.5-1.
Reply | Reply with quote | Quote
0 # actually seekoblitz 2011-10-27 05:36
I forgot sqy something. I can run post viewer, but, course, out of the pgadmin.
Reply | Reply with quote | Quote
0 # Re:tuxman 2011-10-27 08:51
Hi Rodrigo,

have you already tried the new version?:

It has a simplified installation.

Reply | Reply with quote | Quote
0 # Re:koblitz 2011-11-01 12:48
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,

Reply | Reply with quote | Quote
0 # Re: actually seekoblitz 2011-11-01 13:19
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?
Reply | Reply with quote | Quote
0 # Re:tuxman 2011-11-01 20:32

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 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.



Reply | Reply with quote | Quote
0 # re: actually seekoblitz 2011-11-03 15:50
Hi German,
I write plugin.ini exactly like recommend here. Ok it's work. thanks!
Reply | Reply with quote | Quote
0 # Please HelpNeeraj Kumar 2014-07-16 21:05
can anyone xplain this for qgis 2.0.1,posgresql 9.3.4 and postgis 2.1.3.
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.
Reply | Reply with quote | Quote

Add comment

Security code


On-line users