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.
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)
This will load the Data Sources dialog. Select PostGIS from the list and click Next.
Enter the connection details shown below, and click Next.
Host
localhost
Port
5432
User Name
postgres
Password
postgres
Store Password
(Checked)
Select workshop from the Database drop-down box and click the List button.
Select at least one table from the list to validate the connection and enable the Finish button. Click Finish.
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.
Right-click on the layer medford_citylimits and select Add to Current Map.
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.
Do the same for medford_parks and medford_hydro.
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....
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.
Click on the colour swatch next to the Line checkbox. This will bring up a colour selector.
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.
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.
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.
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%.
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.
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.
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.
The application will pause as it scans the database and defines the colour scheme. Once it’s complete, click OK.
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.