I started by examining the data that I had loaded into the database. This ability to run fairly standard SQL queries against my spatial data is one of the main strengths of using a spacial database. Having read the Strategi documentation I knew that there were two columns in each table that I was interested in: code: a numeric feature type identifier and legend: an English language description of the feature type. For example I ran the following SQL against the strategi_region table:

This simple SQL statement selects the code and legend columns from the strategi_region table, and the DISTINCT keyword limits the query to returning only a single row for each match. The output shows that there are 6 different types of feature stored in the table. I ran the same query on the strategi_line and strategi_point tables returning 73 and 89 features respectively.

Once I knew what the data in my database represented I could turn my attention to creating a map. As a first step I decided to use the Quantum GIS (QGIS) desktop GIS application. To install QGIS I used yum from the command line:

sudo yum install qgis

With QGIS installed I launched the program from Applications Menu -> Graphics -> Quantum GIS. When QGIS launched I was presented with a fairly typical application layout: menus across the top, a toolbar, and then a couple of blank areas where the data would be represented. For more details on the QGIS interface and capabilities have a look at the manual (PDF).

There are a number of ways to add a new PostGIS layer to QGIS (see the manual for details). I used the menu option: Layer -> Add PostGIS Layer. This launches a new window:

Add PostGIS Layer

The first thing I did was to configure a new database connection by clicking on the New button and filling in the details in the resulting window:

New database connection

The fields should be pretty self explanatory, the username and password are those I entered when I created my database user previously. I unselected the “Allow geometryless tables” option as this reduces the clutter on later screens by only showing tables with geometry columns. Once I filled in the details I clicked the Test Connect button which confirmed my setup was working, then I clicked OK.

I was then returned to the Add PostGIS Table(s) window where the connect button was now enabled. Clicking on this button showed me the tables in my database that had geometry:

Connected to the database

Selecting the strategi_line table allows me to click on the Build Query button which launches the query builder window:

The query builder window

From the screenshot you can see that I’ve started to build an SQL query to select a subset of the data in the table. In this example I’m selecting on code = 5110, this is the code for Coastline (Natural). Clicking on the Test button pops up a window telling me how many rows are returned by the query and I then click on OK. Back in the Add PostGIS Table(s) window clicking on Add finally adds my new layer to QGIS and gives me a map with an outline of the UK:

Showing the coastline of the UK

I renamed the layer by right clicking on the layer name and selecting Rename from the context menu, I also changed the line colour by right clicking on the layer name and selecting Properties from the context menu. I then went ahead and added a number of other layers from PostGIS by repeating the previous steps but selecting for different feature codes. An excerpt from the resulting map:

When adding the additional layers I combined feature codes using the boolean functions in SQL, for example there are three sequential codes that cover the polylines that represent canals: 5240, 5241, and 5242. So in query builder my SQL looked like:

"code" >= '5240' AND "code" <= '5422'

I like the simplicity of creating a map with QGIS, but I feel the styling of the map is cumbersome and limited. Next I’m going to try to create a more complex map using Mapnik to render the image.

Thank you so much for the post. I have a problem in loading PostGIS table into QGIS. In the dialog window “Add Postgis Table(s), I cannot found the recently created tables in the database PostgreSQL. So I cannot load it into GGIS project. Before this, I found new created layers in the window with the value “Waiting” in the column Type, but now there are only POLYGON, LINE, MULTIPOLYGON, and POINT appear in the column Type. Kindly give me your solution to my problem. Thank you