Newsflash
| Quantum GIS Version 0.11.0 has been released. It is available in source form, and as binary executables for Microsoft Windows, Mac OS X, and GNU/Linux. All versions can be obtained from our download page. If the version for your platform is not available please check back in a day or two as some packages are still being built. |
| How to use QGIS as the front end to a photo database |
|
This HowTo describes one approach to using QGIS to access a photograph database, and view the photographs on screen. It assumes the user is familiar with the use of QGIS and PostGIS (and that you have a point location for each image).
The first thing you will need to use QGIS as a way to access and view images is a spatially enabled database which stores information about the images. A simple, but effective, PostGIS table which functions as a photo/image database is: photo_id int4 (primary key) file_path varchar name varchar keywords varchar label varchar description varchar geom geometry (point)This table has a primary key which uniquely identifies each record in the table, the directory (or folder) the image is stored in (the file_path), the name of the image in this directory, any keywords appropriate to help search for the image (eg: flower, cloud, church) and, a short text field to use as a label as well as a longer text descrition. Also a geometry field for storing the coordinates of the of the subject. A more complex structure can be useful, such as lookup tables for keywords or adding categories of images as well as keywords. For example, a cateogory could be cloud, with keywords of cirrus, cumulus, stratus, etc. This two tiered search approach is more suitable for larger databases, it is up to you to decide exactly how to store your data. Providing the path/name/geometry fields are present and used, QGIS can display your images on screen. The keyword column is there to make finding suitable images easier. Once you have created the table and added at least one record describing a photograph you can set up QGIS to access the table. Start QGIS and connect to the PostGIS database with the image table. Open the image table. Open any other background layers you want, such as georeferenced images, vector roads, etc so the locations of the images are given some useful context on screen. You will need to choose a program QGIS can use to open the images. There are many available, from powerful editors like the GIMP, to simpler ones like kview, xv and gqview. Generally the simpler the program the better, as all we want to do is view the image, but if your needs vary, choose a different program. I have found gqview is a suitable one to use. Edit the properties of the image database layer, and choose actions. An action is simply an external program which QGIS can invoke for you, passing information about the item to the external program. In this case we will need to choose the image viewing program (gqview in this example). In the action dialog box, you can either type in the action to associate with the table, or use the GUI action builder. The action is going to be to start gqview, with the full path and name of the image as a parameter.
In the dialog, define the action as:
<b>gqview %file_path/%name</i></b>
then name the action viewer, add and save.
What QGIS will now do for you (when you invoke the action) is get the data in the file_path and name fields from the table, and start gqview with this information so gqview will start, and open the selected image. Exit the action dialog (make sure you have saved the action first). Make the image layer in QGIS the active layer for searches, etc. Zoom to the region you desire and choose the info tool. Click on a point representing an image. A QGIS dialog displaying the information in the database table will pop up. To invoke the action, right click in this dialog, and click the action to run (viewer). The image will be displayed on screen. There are several enhancements possible to this basic QGIS operation. Perhaps the most useful is to enter a where clause when you open the image table as a QGIS layer.
Assuming you have used "church" and "castle" as two keywords in your image database, you can double click the table name, and in the popup dialog, you can type in:
keywords like '%church%'
then open the layer. Then open the same image table again but this time for your where clause use:
keywords like '%castle%'
Change the symbology for each layer so they display as you prefer, and QGIS will show the locations of both categories of image, using a different symbol/color for each. You can configure each layer to make QGIS label each point with the image name or short description field as appropriate. |


