QGIS

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 »

Simple binary raster reclassification in QGIS

The Raster Calculator in QGIS allows you to run any expression on a raster or collection of rasters. While it is definitely useful, exactly how to phrase your expression in order to reclassify a raster is not always clear. Let’s say you have a raster with values between 0 and 255, and you want everything between 100 and 150 set to 1 (and the rest to 0). If you’re like me, your first instinct would be to write an expression that looks somewhat like this:

((raster@1 > 100) AND (raster@1 < 150)) = 1 else = 0

However, this does not work. In fact, in my case it returned the opposite of what I wanted (and without the “else …”, it returned nothing at all). Instead, the proper way to do it turns out to be this:

((raster@1 < 100) OR (raster@1 > 150)) = 0

Whatever is not set to zero by this statement will be set to 1 instead.

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 »

Quick Git tip: blast from the past

This has been happening to me often lately:

“Rats, this function is broken when I try to do XYZ. But why? I know it worked last week before I started messing around with it. I wasn’t testing the currently broken aspect of it in the interim, though, and I can’t remember what it looked like two weeks ago. When it was working.”

Fear not! Do this:

git checkout some_branch@{"2 weeks ago"}

 

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.

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 »

Upgrading a database to PostGIS 2

Recently I needed the function ST_Split for various and sundry reasons, only to discover that I couldn’t use it in my database. The reason was that ST_Split is a new function introduced in Postgis 2.0, and the database was still in 1.5.3. Obviously, time for an upgrade.

I began following the upgrade process, which I’ll summarize 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 »