spacedman's blog

Contour Lines in Qgis

What with the GSoC project and all the other general discussion about analysis tools in QGis, I got somehow sidetracked into pondering how to do contour maps in QGis. There's the hard way: writing a bunch of C++ code to implement a contouring algorithm, then hooking that into QGis and into the GUI for raster drawing properties. Ah, no.

Writing a Renderer in Python

For my project I want to display point data in pretty colours. I have survey data for villages that record the number of cases of disease and the village population, and I want to colour according to the percentage infected. Red for high, green for low.

Writing a QgsMapTool in Python

For my project I need to give the user three ways to define a rectangular area: it can be the bounding box of a layer, it can be the current view area, or it can be defined by the user drawing a rectangle. My main dialog covers the first two options with a dropdown and a push button, but the third option meant writing a map tool - in Python of course!

The code and details are downloadable from my site.

QGis and Python and R and statistics

Last year I worked on integrating some statistics code with a GIS. After looking at as many open-source cross-platform GIS as I could find, I got stuck with OpenEV. It did the job - just. Its big attraction for me was the built-in python scripting and API - a python script could create new menu items, Gtk dialogs, access map data, create new layers and so on.

My code had to talk to R, a statistics package (www.r-project.org). I did it using Rserve - in this way, R opens a socket on localhost and listens for requests. There were no python bindings for Rserve so I dissected the protocol and wrote my own. Job pretty much done.

Then late last year I upgraded my desktop box to Ubuntu (from RH8). Upgrade time for R, OpenEV, python and so on. Plus the realisation that this code would all have to run on Windows, by non-geeks, in remote villages in Africa.

Syndicate content