OpenGeo

Introduction to PostGIS

Previous topic

Section 13: Query Plan Analysis

Next topic

Section 15: Validity and Equality

Section 14: VisualisationΒΆ

This section will provide an overview to using the uDig desktop application to view data from your PostGIS database.

uDig is located in the software\udig\ directory of the workshop materials and can be started by double-clicking udig.bat. A splash-screen will display for a few moments while loading the application, and when done the following screen will appear.

_images/visual-01.png
  1. The first step to using uDig with our data is to import our database into uDig’s catalogue. To do this, close the Welcome screen, then click on Layer Menu > Add... (or press Ctrl-A, L)

    _images/visual-03a.png
  2. This will load the Data Sources dialog. Select PostGIS from the list and click Next.

    _images/visual-05.png
  3. Enter the connection details shown below, and click Next.

    Host

    localhost

    Port

    5432

    User Name

    postgres

    Password

    postgres

    Store Password

    (Checked)

    _images/visual-06.png
  4. Select workshop from the Database drop-down box and click the List button.

    _images/visual-07.png
  5. Select at least one table from the list to validate the connection and enable the Finish button. Click Finish.

    _images/visual-08.png
  6. To see more layers, expand the navigation tree by clicking the [+] beside the PostGIS localhost/workshop item in the Catalog pane. Expand the public schema as well. You will now see a list of tables and views available in the database.

    _images/visual-09.png
  7. Right-click on the layer medford_citylimits and select Add to Current Map.

    _images/visual-10.png _images/visual-11.png
  8. This will add this layer to the map. This layer in itself isn’t too interesting, so let’s add a few more. Click and drag the layer jacksonco_streets from the Catalog view and drag onto the Layers view.

    _images/visual-12.png
  9. Do the same for medford_parks and medford_hydro.

    _images/visual-13.png
  10. These layers will form the basemap over which we will display the results of various queries. But the automatically chosen colours are rather inappropriate. Right-click on medford_hydro in the Layers pane and select Change Style....

    _images/visual-14.png
  11. The style dialog provides a number of views to allow the editing of the layer’s style. By default, we are on the Simple Feature page.

    _images/visual-15.png
  12. Click on the colour swatch next to the Line checkbox. This will bring up a colour selector.

    _images/visual-17.png
  13. Select your favourite shade of water blue and select OK on both the colour selector and the Style Editor. The medford_hydro layer will now be rendered in your selected blue.

    _images/visual-18.png
  14. Repeat this process to make the medford_parks layer green. This time there are two colours to select. The Line colour will be used to draw the outline of the park, while the Fill colour is used to fill in the polygon. Select the same colour for both.

    _images/visual-19.png
  15. We now want to make the medford_citylimits layer less obtrusive. Load the Style Editor and select a light grey for both Line and Fill.

    _images/visual-20.png
  16. Next, cut the opacity of both Line and Fill by half. This is done using the drop-down boxes at the right of each line. Note that the Fill is 50% opaque by default, so reduce this to 25%.

    _images/visual-21.png
  17. Finally, let’s see how we can visualise some slightly more complex data. From the Catalog view, drag the agebysex layer into the Layers view. Next load the Style Editor only this time, select the Theme page from the list on the left. This will load the uDig thematic style builder.

    _images/visual-22.png
  18. This dialog builds styles based on selected attributes and colour schemes. To start, select the median_age_female attribute from the Attribute drop-down box. Next select 10 under Classes. Next, Quantile from the Break box. Finally, median_age_total under Normalize, as shown below. The resulting theme will create 10 different styles, created by dividing the values of the median_age_female attribute by median_age_total and breaking the results into 10 classes containing equal numbers of results.

    _images/visual-23.png
  19. With the attribute details defined, let’s find a nice colour scheme. To start, we need to decide what we’re trying to view. Because the data is being normalised, it makes the most sense to select a diverging colour scheme, one that highlights the low and high values and plays down the median values. Under the drop-down box labelled Show, select Diverging. This will filter the available palettes to only diverging colour schemes. The other options Sequential, or a sequence of colours that moves steadily from low to high hue, and Categorical, or sets of colours that are easily distiguished from one another but don’t represent relative magnitudes. In the Palette list, find and select RdBu.

    _images/visual-24.png
  20. The application will pause as it scans the database and defines the colour scheme. Once it’s complete, click OK.

    _images/visual-25.png
  21. You will have to zoom out and turn off the jacksonco_streets layer in order to see the themed layer clearly.

Thematic styling provides a quick and powerful way to explore your spatial data as you experiment with different queries. Throughout the remainder of this workshop, various examples will be given that create new tables or views that can be visualised in a client such as uDig to better understand the results.