For English click here.
RT Sql Layer es un plugin de QGIS escrito por Giuseppe Sucameli para Faunalia y Regione Toscana-SIGTA, el cual a su vez está basado en el plugin PostGIS Manager de Martin Dobias. El plugin fue adaptado al visor de PostGIS y fue agregado siguiendo el post llamado Cargando plugins de QGIS en el visor de PyQGIS. De la misma forma, sería posible adaptar otros plugins de QGIS para ser incluidos en el visor de PostGIS para pgAdmin.
Capturas de pantalla en Ubuntu/Linux:


PRERREQUISITOS
Python, PyQt4, PyQGIS, libqt4-sql-psql y psycopg2 (para el constructor de consultas).
Cómo instalar prerrequisitos en Windows: Ver este post, además se requiere instalar psycopg2 desde OSGeo4W.
Cómo instalar prerrequisitos in Ubuntu/Linux: Para QGIS, ver la página oficial de descargas. Para los demás programas usar apt-get o Synaptic.
INSTALACIÓN
Esta vez el proceso de instalación ha sido reducido a extraer un archivo ZIP (descargar el archivo zip) en la ruta adecuada (en Windows: C:/Archivos de programa/PostgreSQL/8.4/bin/ mientras que en Ubuntu/Linux: /usr/bin/) y editar el archivo plugins.ini de pgAdmin.
En Ubuntu/Linux se requiere el comando sudo para extraer y definir permisos 755 sobre los archivos extraidos, de esta manera:
sudo unzip postgis_viewer.zip -d /usr/bin/
sudo chmod 755 /usr/bin/postgis_viewer/ -R
Adicionalmente, copiar las siguientes líneas a /usr/share/pgadmin3/plugins.ini (si el archivo no existe, debe ser creado):
Title=View PostGIS layer
Command=$$PGBINDIR/postgis_viewer/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
En Windows editar C:/Archivos de programa/PostgreSQL/8.4/pgAdmin III/plugins.ini agregando las siguientes líneas:
Title=View PostGIS layer
Command="$$PGBINDIR\postgis_viewer\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\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.
Capturas de pantalla en Windows:


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.
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/
- RT Sql Layer 1.0.14. Giuseppe Sucameli for Faunalia and Regione Toscana-SIGTA http://www.faunalia.it/qgis/rt_sql_layer.zip
Comments
Ahora la consulta: He visto en las imagenes de tus publicaciones que estas visualizando una capa raster desde la base de datos.
En Ubuntu 10.10 tengo PostgreSQL 9.0 y Postgis 2.0.0SVN donde ya esta integrado la extension Postgis Raster (antes wktraster).
¿Cual debería ser la estructura de una tabla con información raster?.
¿Que detalle debo tener en cuenta para poder ver mis capas raster en el visor?
gracias.
bueno, probe el plugin con capas ráster en Windows, supongo funciona en Linux.
La estructura de las tablas la puedes consultar en este enlace (trac.osgeo.org/postgis/wiki/WKTRaster/Documentation01).
En todo caso, para cargarlas a tu BD debes usar la utilidad gdal2wktraster.py, en este enlace (trac.osgeo.org/postgis/wiki/WKTRasterTutorial01) hay un ejemplo de cómo cargar rásters.
Por lo demás, en tu base de datos seleccionarías tu tabla ráster y al dar click sobre el plugin de pgAdmin tu ráster sería cargado al visor.
NOTA: El constructor de consultas SQL hasta donde conozco, funciona solo para vectores.
Saludos.
Queria comentarte varios puntos:
-El visor de capas me funcionó en Ubuntu, pero solo con vectores. No he podido visualizar las capas raster cargadas en la base.
-Desde la versión Postgis 2.0.0.El comando para crear el sql a incorporar en la base de datos es "raster2pgsql.py".
-Ya tengo incorporadas las tablas raster en mi base con la estructura que me indicas. Pero no consigo visualizarlas en el visor de pgadmin.
Pregunta: ¿Has usado en Quantum Gis el plugin Postgis Wktraster? En Ubuntu y Windows tengo la misma version de QGIS (1.6). En Windows pude cargar las capas raster, pero no en Ubuntu. Me da el siguiente error: Could not connect PG: dbase....
Cuando pruebo la conexión a la base se conecta correctamente. Es mas el el plugin me permite seleccionar la capa, pero cuando intento cargarla me da el error que mencione.
Hasta ahora no puedo visualizar de ninguna forma (ni con Quantum, ni con el visor de pgadmin) mis capas raster.
Gracias.
Gracias por la información,
Tuxman
Ante todo darte las gracias por hacernos a los que no somos desarrolladores y trabajamos en temas GIS mas fácil. Conseguí instalar sin problemas la aplicación y funciona perfectamente, la verdad es que está muy bien ver las capas espaciales visualmente desde el propio postgis, yo había utilizado el phppgadmin pero modificado para que si contabas con una instalación de mapserver se pudiera visualizar la capa.
He estado intentando localizarlo de nuevo pero no lo he encontrado.
Un saludo
I just came across your promising looking PostGIS Viewer and have decided to test it. However, I've stumbled across an issue. Whenever I try to start the script from Konsole, I receive the following output
python /usr/bin/postgis_viewer/postgis_viewer.py -h localhost -p 5432 -U postgis -W MyPass -d postgis -s public -t roadtrl020
I: Starting viewer
I: Database connection was succesfull
E: Error. Exiting
Layer 'public.roadtrl020' doesn't exist. Be sure the selected object is either raster or vector layer.
I am connected to postgis database with credentials that've provided to script
ps ax | grep 5432
/usr/lib/postgresql/9.1/bin/psql -U postgis -d postgis_20 -W -p 5432
It happens in pgadmin too.Any ideas regarding this issue would be very welcome.
first of all, I recommend you using the newest version of the plugin [1].
Regarding the problem, please tell me whether this SQL query returns any row:
--
SELECT column_name FROM information_sch ema.columns
WHERE table_schema = 'public' AND
table_name = 'roadtrl020' AND
udt_name = 'geometry' LIMIT 1
--
If that's not the case, please let me know the CREATE TABLE statement for such a table.
Regards,
Tuxman
---------------------
[1] http://geotux.tuxfamily.org/index.php/en/geo-blogs/item/293-consola-sql-para-plugin-pgadmin-postgis-viewer
I have just found out that if you want to view postgis spatial tables through Postgis Viewer that it works only through pgAdminIII and for tables with geometry data type.
Now it works through pgAdmin but still fails via konsole (bash)
python /usr/bin/psviewer/postgis_viewer.py -h localhost -p 5432 -U postgis -W myPassword -d postgis -s public -t roads
and if the table is of 'geography data type' with the following error
"Layer 'x.y' doesn't exist. Be sure the selected object is either raster or vector layer."
All the best,
Damijan
the new version of the plug-in now includes support for the 'geography' type. Have a look at [1].
Concerning the problem you mention with the console, that's quite strange. If it fails from the console, it should also fail from pgAdmin, there is no reason (that I know) why it would behave differently. I haven't been able to replicate the problem but I'll keep an eye on it.
Thanks for your suggestions and your detailed reports.
Regards,
Tuxman
----------------
[1] http://geotux.tuxfamily.org/index.php/es/geo-noticias/item/293-consola-sql-para-plugin-pgadmin-postgis-viewer#comment-440
I have just restarted my PostgreSQL database and this issue mysteriously disappeared. I did hot upgrade of pg database two months ago and haven't stopped database and rebooted my system since then. However, I've just rebooted my system, started my database and voila it works now
Yay. Your plugin works from console and pgadmin
Cheers,
Damijan
did you test to run PostGIS Viewer with OSGeow64 (on windows 7)?
is it possible or not at all ?
I try without success ! dommage ...
Denis
Buenos días todos ,
is somebody test test to run PostGIS Viewer with OSGeow64 (on windows 7)?
is it possible or not at all ?
I try without success ! dommage ...
i just see icon 'view Postgis Layer" in pgAdmin3
Denis
RSS feed for comments to this post