For English click here.
Con base en el plugin de Mauricio de Paulo llamado WKTRaster para QGIS, fue posible agregar el soporte raster al plugin. De la misma forma, con algunas modificaciones a la tabla de contenido para aplicaciones basadas en PyQGIS se adicionó una tabla de contenido básica para desplegar varias propiedades de las capas.
Esta es una captura de pantalla (Windows):

Como el proceso de instalación ahora incluye una carpeta, que de hecho es opcional, creo que es recomendable mostrarlo una vez más:
PRERREQUISITOS
Python, PyQt4, PyQGIS y libqt4-sql-psql.
Cómo instalar prerrequisitos en Windows: Ver blog.
Cómo instalar prerrequisitos en Ubuntu/Linux: Para QGIS, ver página oficial de descargas. Para los demás programas usar apt-get o Synaptic.
DOWNLOADS
Para Ubuntu/Linux y Mac OS X descargar los archivos postgis_viewer.py y postgis_viewer_imgs.zip.
Para Windows descargar postgis_viewer.py , postgis_viewer.bat y postgis_viewer_imgs.zip.
CÓMO USAR EL VISOR DESDE LA TERMINAL DE COMANDOS
En Ubuntu/Linux, dar permisos de ejecución:
$ sudo chmod 755 postgis_viewer.py
Ejecutar el archivo definiendo parámetros:
$ postgis_viewer.py -h localhost -U postgres -W secreto -s public -t pais -d geodb &
Si se ejecuta de nuevo el comando con otra tabla, esta se carga al visor previamente abierto:
$ postgis_viewer.py -h localhost -U postgres -W secreto -s public -t rios -d geodb
En Windows:
Asegurarse de tener las librerías de QGIS cargadas y ejecutar en una terminal de comandos:
$ c:\Python25\python.exe postgis_viewer.py -h localhost -U postgres -W secreto -s public -t pais -d geodb &
INSTALACIÓN COMO PLUGIN EN pgAdmin3 (PostgreSQL 8.4)
En Ubuntu/Linux:
Copiar el archivo postgis_viewer.py a una de las carpetas de la variable de entorno PATH, por ejemplo, a /usr/bin/
$ sudo cp postgis_viewer.py /usr/bin/
Definir permisos de ejecución sobre el archivo:
$ sudo chmod 755 /usr/bin/postgis_viewer.py
Copiar las siguientes líneas al archivo /usr/share/pgadmin3/plugins.ini (si el archivo no existe, debe crearse):
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
Extraer el archivo postgis_viewer_imgs.zip a /usr/bin (o la carpeta en donde se ubicó postgis_viewer.py) y asignar permiso de ejecución a los archivos:
sudo unzip postgis_viewer_imgs.zip -d /usr/bin/
sudo chmod 755 /usr/bin/postgis_viewer_imgs/ -R
En Windows:
Copiar los archivos postgis_viewer.py y postgis_viewer.bat, y extraer el archivo postgis_viewer_imgs.zip en C:/Archivos de programa/PostgreSQL/8.4/bin/
Editar el archivo C:/Archivos de programa/PostgreSQL/8.4/pgAdmin III/plugins.ini agregando las siguientes líneas:
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
El archivo postgis_viewer.bat se encarga de definir las variables de entorno del paquete OSGeo4W (Qt, Python, QGIS) para posteriormente ejecutar el archivo postgis_viewer.py En el archivo .bat se da por hecho que OSGeo4W está instalado en C:/ y que la ruta para acceder a PostgreSQL es C:/Archivos de programa/PostgreSQL/8.4/ Si se presentara algún inconveniente, se deben revisar dichas rutas.
NOTA: Estas instrucciones están enfocadas en PostgreSQL 8.4 y pgAdmin 1.10. Desconozco el funcionamiento de los plugins en versiones superiores, el cual segun entiendo, ha sido modificado. Cuando sea oportuno actualizaré el post para mostrar cómo configurarlo en PostgreSQL 9.0. En todo caso, es bienvenido cualquier comentario sobre el funcionamiento del visor en PostgreSQL 9.0 y versiones recientes de pgAdmin. Ver actualización 1.
PROBLEMAS CONOCIDOS:
- Con versiones de PyQt4 < 2.6 probablemente se obtendrá un problema en el despliegue de las propiedades de las capas cuando se arrastra una capa en la tabla de contenido. Se puede verificar la versión de PyQt4 desde una terminal de Python de esta manera (si se obtiene una versión menor que 4.6 se requiere actualizar la versión de PyQt4):
>> from PyQt4.QtCore import *
>> VERSION_STR
'4.6'
- Si los íconos de la ventana del plugin no aparecen, verificar las líneas 62 y 65 del archivo postgis_viewer.py. Allí es posible editar la ruta a la carpeta postgis_viewer_imgs. En Ubuntu/Linux se requiere la ruta absoluta a la carpeta, mientras que según las pruebas realizadas, en Windows tan solo se requiere la ruta relativa.
Finalmente, otra captura de pantalla (Ubuntu/Linux):

--------------------------------------------------------------------------------------------------------
ACTUALIZACIÓN (2011/03/09): INSTALAR EL PLUGIN EN PostgreSQL 9.0 (pgAdmin 1.12)
El plugin PostGIS Viewer funciona para versiones de pgAdmin >=1.9 y <1.13. PostgreSQL 9.0 viene con pgAdmin 1.12, por lo cual su instalación es muy similar a las instrucciones expuestas en este post. En todo caso se deben tener en cuenta unas ligeras modificaciones:
PARA WINDOWS:
- La carpeta a donde se deben copiar los archivos postgis_viewer.py, postgis_viewer.bat y a donde se debe extraer postgis_viewer_imgs.zip es C:/Archivos de programa/PostgreSQL/9.0/bin, esto puede variar según la instalación de PostgreSQL, así que debe verificarse que en efecto exista.
- El archivo plugins.ini debe editarse desde C:/Archivos de programa/PostgreSQL/9.0/pgAdmin III/plugins.ini
- Debe editarse el archivo postgis_viewer.bat cambiando la línea correspondiente a la ejecución del archivo postgis_viewer.py. Dicha línea debe quedar así: python "C:/Archivos de programa/PostgreSQL/9.0/bin\postgis_viewer.py" %*
PARA UBUNTU/LINUX:
Las rutas de instalación de pgAdmin en linux no llevan el número de versión de PostgreSQL, por lo que las instrucciones expuestas en este post para PostgreSQL 8.4 deben funcionar para PostgreSQL 9.0.
--------------------------------------------------------------------------------------------------------
REFERENCIAS
- 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/









Comentarios
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!
Suscripción de noticias RSS para comentarios de esta entrada.