Author Archive

Publishing multiple projects with QGIS Server

You know the drill right? You just made a beautiful map for your boss using QGIS Server. Then he walks into your office and says ‘Kiepie, I need another one in a different CRS’. Your heart drops in your chest and your jaw drops to the desk. You can’t do that using QGIS without publishing a whole new virtual host instance right? Wrong…with a little tweaking, you can publish projects in different CRS’s quite easily from the same apache virtual host. Read on after the break to see how…

Read more »

Creating coloured rasters with GDAL

One of the most popular posts on my blog ever is my article about creating GDAL hillshades: ‘A workflow for creating beautiful relief shaded DEMS using GDAL‘. In the techniques outlined in the aforementioned article, colours are assigned across a continuum to and superimposed on top of a hillshaded model. The GDAL tools in QGIS have come along nicely thanks to the work of Guiseppe Sucameli – to the point that you can pretty much do the workflow from the aforementioned article within the QGIS gui environment now (barring some simple text file editing activities).

Sometimes one wants to simply assign arbitrary colours to pixel values of a raster to create a colour map. You can do this with QGIS, but the results are not persistent in the dataset, which I needed because I wanted to create my own colour map and then merge that raster with a shaded relief model. There was one extra requirement I had – I wanted to create my colour map based on polygonal areas at the beginning of my workflow. In this article I describe how I went about creating a hillshaded relief model using a polygonal overlay to define my height classes. I’m also going to show the mis-steps I took to give you a more realistic view of the process of doing such work. Read on for details…

Read more »

Vector transparency plugin for QGIS

Yesterday I wrote a new little plugin for QGIS. It is available here: http://plugins.qgis.org/plugins/VectorTransparency/ or if you prefer to get it from GIT then here: https://github.com/timlinux/VectorTransparency. You can also get the plugin by adding the new QGIS official repository (which will be available by default from QGIS 1.8 onwards) to your repository list:

http://plugins.qgis.org/plugins/plugins.xml

The plugin is very simple but saves me hours of work. When I have complex symbologies e.g. a vector layer with many categories and I want to update the transparency level of all symbols, the process is very tedious and involves clicking on each symbol and shifting the transparency slider until I get the correct value. I need to repeat this for each symbol in the layer. My new plugin does all this in one go for you. Here are a couple of screenies that illustrate its use.

The Hoyde2 layer - all symbols are opaque (click for larger image)

The Hoyde2 layer - all symbols are opaque (click for larger image)

Using the VectorTransparency plugin to update transparency of all layers (click for larger image)

Using the VectorTransparency plugin to update transparency of all layers (click for larger image)

The Hoyde2 layer - all symbols are now transparent (click for larger image)

The Hoyde2 layer - all symbols are now transparent (click for larger image)

 

Update: It seems doing this in the symbology tab of QGIS is possible – just select all the symbol classes, right click and choose set transparency from the context menu. I’ll leave my plugin foating around though since it is probably quicker to use when you want to update many layers. Thanks to the folks on #QGIS irc channel for bringing this to my attention.

Understanding the South African Coordinate Reference System

A nice article by Aslam Parker, Chief Directorate: National Geo-spatial Information, South Africa was published this month in our local GIS/Surveying magazine ‘Position IT‘ that describes the South African CRS. It probably would be of general interest to those trying to understand CRS concepts too. Direct link to the PDF here.

Remote debugging QGIS python plugins with PyDev

In two previous articles (one one using Eclipse to build QGIS, and the other on using Eclipse as a Django development platform), I mentioned I would delve a little into using the Eclipse environment as a platform for QGIS Plugin Development. In particular we are interested in using Eclipse as a remote debugging platform. What does that mean? It means that Eclipse/PyDev will be able to attach itself to your plugin running withing QGIS and then step through the plugin code line by line, inspect variables and so on. This is incredibly useful as it allows you to break away from the very bad ‘code, launch plugin, hope for the best’ development process to one which is much more rigourous and time effecient. This article describes the process I followed to get everything set up for remote debugging with Eclipse/PyDev effectively. I also throw in a couple of other tips on how to use PyDev as an effective plugin development platform. Read more after the break below….

Read more »

Django : Faking it with South

So we use the super awesome South to manage schema changes when we change our django models. Basically South works in the background to make sure that your database is always in a consistent state with your models. Recently I have been adding South to a project and deploying these updates to my server. One of the tricky things I found is letting South know when your database is already in a consistent state and that it should mark its migration history as being up to date. Today I had a few moments to properly figure out how to do this. You can substitute RTFM for ‘figure out’ as you prefer. The trick is to do a fake migration like this:

python manage.py migrate someapp 0001 --fake

With 0001 being the migration state that you want to tell South that you are now at. This is documented here. One other noteworthy tip is that in the course of our updates, we are switching from Django 1.2.1 to 1.3.x and South gave me some pretty confusing error messages like this:

Traceback (most recent call last):
  File "manage.py", line 11, in <module>
    execute_manager(settings)
  File "/home/web/sac/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/home/web/sac/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/web/sac/python/lib/python2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/web/sac/python/lib/python2.7/site-packages/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "/home/web/sac/python/lib/python2.7/site-packages/south/management/commands/schemamigration.py", line 83, in handle
    if migrations.app_label() not in getattr(last_migration.migration_class(), "complete_apps", []):
  File "/home/web/sac/python/lib/python2.7/site-packages/south/migration/base.py", line 307, in migration_class
    return self.migration().Migration
AttributeError: 'module' object has no attribute 'Migration'

I did’t really find any useful help on google, but eventually resolved the issue by removing the .pyc files from the app/migrations/ folder and then everything just worked like magic.

 

Django development with Eclipse and PyDev

Eclipse is a Java IDE right? Wrong! You can use it for other languages too! I have been needing to improve my debugging techniques for python and Django (more on that in the future). This post outlines how you can set up Eclipse with PyDev to work on an existing Django aplication. The benifits? A complete IDE environment with a debugger that will let you set breakpoints anywhere in your app and interactively step through the code from that point.  You also get other nice things like refactoring support, code completion and so on. I’m still a dyed in the wool command line user since I can use my same development environment both locally and on a remote server effortlessly,  but for training courses and those who prefer to use a GUI, PyDev on Eclipse will probably make a compelling alternative. lets see how to get is set up (after the break below)…

Read more »

A nice QGIS tutorial by Lex Berman

Lex Berman from Harvard just dropped me a nice email with a link to an interactive QGIS tutorial he has created. The tutorial is one of the nicest I have seen – each section is detailed with text, screenshots and howto videos.  I thought I would make a quick post about it here so the rest of the world can enjoy it too!

Lex's cool online tutorial (click to visit the site)

Lex's cool online tutorial (click to visit the site)

Compiling QGIS with Eclipse CDT on Ubuntu

Everything I’m about to tell you you should probably forget – in my brief experience with it, Eclipse makes for an inferior alternative to Qt Creator if you are looking for a GUI to do development on QGIS with. That said, there are those for whom Eclipse is their weapon of choice. My primary motivation for testing eclipse was that I wanted to use the Eclipse refactoring tools which in days of yore when I did a lot of Java programming proved to be the IDE’s saving grace. I wanted the refactoring tools because for QGIS 2.0 we are planning an API cleanup and I was hoping that it would make the process easier. Ok so let’s dive in (read on after the break for details)

Read more »

Work mantras – an off FOSSGIS topic post

Running a small business is a challenge. I came into this as a FOSS geek with a grandiose plan of spreading the FOSS GIS goodness far and wide and somehow earning a living from it. I don’t have an MBA or any significant business skills so I have been learning everything from first principles as I go along. Using Scrum project management has been a huge step forward for us and has been instrumental on us creating a much more effective work process within the office. The next biggest challenge we have faced on our journey is how to motivate and get the best out of our staff. Having staff is a double edged sword in a small business – they can boost your productivity and earning power, but they also cost a lot of money and time (training and supervision). One of the things we do with our staff is have a bonus system whereby a percentage of their salary is dependent on performance. This theoretically motivates them to work harder to achieve their maximum earning power.

Read more »