Module 1d, Learning the basic concepts of GeoDMS, classifying and visualising data

learning objective: learning how to classify data and configure visualisation styles for thematic maps

introduction

In the previous module, we learned about relations between domain units. A special and very common use of relations is classification: relating a numeric attribute to a small set of classes. The result — a classified thematic map — is one of the most common outputs of a GeoDMS model.

Classifying data in the GeoDMS means relating a numeric attribute to a class unit via a class breaks attribute. Each value in the original domain is assigned to a class based on where it falls between the class breaks.

In this module, we first look at the default classification the GeoDMS GUI provides, then at how to configure a class unit explicitly for full control over classes and visualisation styles.

default classification in the GUI

Open the GeoDMS GUI, load the exercise configuration, and double-click on SourceData/province/inhabitants in the tree view. A thematic map opens with a default classification: the GUI automatically divides the values into 8 classes and assigns colours.

In the legend, you see the class index (0..7), the lower class break for each class, and the count of provinces per class. The original province domain with 12 entries has been related to a class domain with 8 entries.

This is convenient for a quick visual inspection, but the number of classes, the class breaks, and the colours are all determined automatically. To control these, you need to configure a class unit explicitly.

configuring a class unit

A class unit is a small domain unit that defines the classes. A typical class unit looks like this:

unit<uint8> province_size : nrofrows = 4
{
   attribute<nr_inh>  ClassBreaks  : [0, 500000, 1000000, 2000000]
                                   , DialogType = "Classification";
   attribute<uint32>  BrushColor   : [rgb(255,255,204), rgb(161,218,180),
                                      rgb(65,182,196),  rgb(34,94,168)]
                                   , DialogType = "BrushColor";
   attribute<string>  Label        : ['< 500k', '500k - 1M', '1M - 2M', '> 2M'];
}

Some characteristics of a class unit:

  • The value type is usually uint8, as the number of classes is typically less than 256.
  • The number of rows is explicitly configured with nrofrows or a range function.
  • A ClassBreaks attribute defines the lower bound of each class. The upper bound is the lower bound of the next class. The last class has an open upper end.
  • The DialogType = "Classification" property marks this as the classification attribute.
  • One or more visualisation style attributes (BrushColor, PenColor, SymbolColor, etc.) are configured for the class unit. See visualisation styles for a complete overview.

using a class unit

There are two ways to link an attribute from the original domain to a class unit:

Option 1: explicit relation using classify

attribute<province_size> size_rel (province) :=
    classify(inhabitants, province_size/ClassBreaks);

This creates a new attribute size_rel in the province domain. Its values are index numbers into the province_size class unit — in effect, a relation from province to province_size. When this attribute is displayed in a map view, the GeoDMS uses the BrushColor defined in province_size to colour each province.

Note: (.) in a domain specification refers to the parent item of the current item as the domain unit. You may encounter this in nested configurations where the parent unit is the implied domain.

The explicit relation can also be reused for other purposes, such as aggregating data by class.

Option 2: implicit classification via the cdf property

The cdf (Classification Distribution Function) property links an attribute or values unit to a class unit without creating an explicit relation:

// on the attribute itself:
attribute<nr_inh> inhabitants (province)
    : cdf = "province_size/ClassBreaks";

// or on the values unit:
unit<float32> nr_inh
    : cdf = "province_size/ClassBreaks";

When inhabitants is shown in a map view, the GeoDMS GUI applies the classification and colours from province_size automatically, just as it does for the default classification. No separate size_rel attribute is created.

The difference: option 1 produces an explicit relation that can be inspected and reused in expressions; option 2 is implicit and only affects visualisation.

visualisation styles

The DialogType property tells the GeoDMS GUI how to use each attribute in a class or code unit. Common values are:

DialogType Purpose
"Classification" marks the class break attribute
"BrushColor" fill colour for polygons and grid cells
"PenColor" outline colour for polygons and arcs
"SymbolColor" colour for point symbols
"LabelText" text shown in the legend

Visualisation styles differ for point, arc, polygon, and grid data. It is important to match the style type to the geometry type of the data you are visualising. See visualisation styles for the full reference. The LabelText property does not need to be configured if the attribute is already named Label and is configured as a direct subitem of the domain unit.

class units versus code units

Class units and code units both serve as the basis for thematic maps, but they are used for different kinds of data.

Class units (with a ClassBreaks attribute) are for numeric data that is classified into ranges — such as population, income, or distance. The number of classes is chosen by the modeller.

Code units define the unique occurrences of categorical data — such as energy labels (A through G), land-use types, or road categories. Each code is a distinct category, not a range.

An example of a code unit for energy labels:

unit<uint8> EnergyLabel : nrofrows = 7
{
   attribute<string>  Label       : ['A','B','C','D','E','F','G'];
   attribute<uint32>  BrushColor  : [rgb(0,255,0),   rgb(35,215,0),
                                     rgb(70,175,0),  rgb(105,140,0),
                                     rgb(140,105,0), rgb(175,70,0),
                                     rgb(210,35,10)]
                                  , DialogType = "BrushColor";
}

If the number of codes is known, configure nrofrows explicitly rather than using unique. The relation from the data to the code unit is typically made with rlookup:

attribute<EnergyLabel> energy_label_rel (vbo) :=
    rlookup(vbo/energy_label_code, EnergyLabel/Label);

Class units classify numeric data into ranges; code units define fixed sets of categories.

try it yourself!

In the exercise configuration (GeoDMS_Academy/basics_classify_and_visualise/cfg/exercise.dms), configure the following:

  1. A province_size class unit with 4 classes of your choice. Configure both ClassBreaks and BrushColor.
  2. Use option 1 (classify) to create a classified thematic map of inhabitants.
  3. Use option 2 (cdf) to achieve the same result without an explicit relation.
  4. Configure code units for the landsdeel and ligging attributes. Tip: use the unique function to derive the possible codes from the data, then add BrushColor and LabelText.

Open the results in the GeoDMS GUI and compare the two classification options in a map view.

The reference solution is in result.dms in the same cfg subfolder.


Go to previous module: Module 1c, Learning the basic concepts of GeoDMS, calculations over multiple domains

Go to next module: Module 1e, Learning the basic concepts of GeoDMS, reading errors and debugging