QGIS Geometric Class

You are here: Home > Programming > QGIS Geometric Class

QGIS Geometric Class

Graduated symbolology for vector layers is largely used in archaeology, e.g. for classifying with different colors, dimensions or symbols excavation grids, survey's squares, site points, etc.

The graduated symbology is built by the “classification” of a numeric variable: for example, if we have an excavation grid of 60 squares that register the weight of finds for each of them, vector layer classification consists of defining the number of weight's classes (e.g. 5), intervals in which data are grouped (0-10 g, 11-20 g, 21-30 g, etc.) and colors or symbols representing each class.

This classification may be different depending on the different mathematical and statistical method applied. Different classification methods yield different results, as you can see in this picture:

In order to using the proper classification method is necessary to know the shape of frequency distribution that the variable we want to classify assumes: for uniform distributions "Equal Interval" or "Pretty Breaks" methods are good; for normal distributions "Standrd Deviation" or "Quantile" methods are better; for bi- or polimodal distributions "Natural Breaks (Jenks)" method is the best choice.

In Archaeology exponential (positive skewed) distributions are frequent. When we deal with an exponential distribution of our data, the proper classification method is "Geometric Intervals" (Conolly, Lake 2006; Dent 1999. See Reference below).

As far as I know, GIS FLOSS (QGIS, GRASS, gvSIG, Openjump, Saga, etc.) don't include this classification method. I tried to develop it for QGIS using the opportunities provided by its Console Python.

I developed this simple Python code for geometric classification, using the formula suggested by Dent 1999, p. 146 (See Reference below).

def geometric(values, classes):
    _min = min(values)
    _max = max(values) + 0.00001 #temp bug corr...
    X = (_max / _min) ** (1 / float(classes))
    res = [_min * X**k for k in range(classes+1)]
    return res

I inserted these rows in a script that can be run in QGIS Console Python.

For developing this script I used the help of web community, in particular the blog of Carson Farmer (http://carsonfarmer.com/2010/09/playing-around-with-classification-algorithms-python-and-qgis/) and a mailing list reply of Kelly Thomas (http://gis.stackexchange.com/questions/48613/how­to­apply­a­graduated­renderer­in­


Here you can download the files:

geometric_class.py My python script for geometric classification in QGIS
standard_class.py Python script for creating all standard classification methods in QGIS (Equal Intervals, Pretty Breaks, SD, Quantile, Natural Breaks) at the same moment. Code developed by Kelly Thomas (http://gis.stackexchange.com/questions/48613/how­to­apply­a­graduated­renderer­in­
and modified by me.
USAGE.txt A little guide for using these scripts.
sample.tar.gz Sample data for testing scripts.

ATTENTION! The scripts are under development and in need of improvement and testing.


R function classIntervals

During my work, I used R package "classInt" developed by Roger Bivand. I modified it in order to add Geometric Intervals method to the classification methods ("styles") already implemented.

This is my addition:


else if (style == "geometric") {
            k <- (max(var)/min(var))^(1/n)
            brks <- c(min(var),(min(var)*(k^seq(n))))

From here you can download the modified function: classIntervals_mod.



1. Conference Presentations & Slides

Talk about ArchaeoSection in IX ARCHEOFOSS - Workshop Open Source, Free Software e Open Format nei processi di ricerca archeologica (Verona, 19th-20th June 2014).
Download presentation here

2. Bibliography

Dent B. D. 1999, Cartography. Thematic Map Design. Fifth Edition, London, pp. 146; 406.
Conolly J., Lake M. 2006, Geographical Information Systems in Archaeology, Cambridge, pp. 141-­145.


« prev  |   top  |   next »

[24-07-2014] ArchaeoSection 0.1.2

New release with a renewed csv export tool.

See details in Programming Section

[03-07-2014] QGIS Geometric Class

New classification method (Geometric Intervals) for graduated symbology in QGIS.

See details in Programming Section

[19-02-2014] QGIS Archaeological Styles

New custom symbols for archaeological drawings.

See details in Programming Section

Powered by CMSimple | Login