Related Plugins and Tags

QGIS Planet

Vector rule editor and polygon line styles in QGIS

Note: This post discusses features in QGIS Trunk - they will make their way into the future QGIS 1.7.

One of the things I love about QGIS is how people arrive into the developer community and just start pitching in. Its the classic 'scratch your own itch' phenomenon at work and I never grow tired of watching it. This week, QGIS got a couple of interesting new features. The first is and implementation of a graphical rule builder for when you are using rule based vector symbology. Rule based symbologies allow you to create classes of features based on arbitrary rules, but up until now you had to write those rules manually. Nathan Woodrow's recent page implements a query builder that lets you point and click your way to easy rule creation.

Rule editor for vector layers

Another nice new feature was committed by Martin Dobias this week. It allows you to treat the stroke / outline for polygons as a separate entity when rendering. So now you can render a polygon with one or more discrete line styles as seen in the image below. In addition you can render a marker in the polygon centroid. The cartography capabilities in QGIS are really looking good these days and I have seem some beautiful maps that folks have come up with using the new generation symbology.

In QGIS 2.0 we will drop the old symbology implementation  - but I get the feeling most won't miss it very much. The only time I ever use the old symbology implementation is when I am exporting projects to mapserver or mapnik.

Custom line layers for polygon feature outlines

3d visualisation and DEM creation in QGIS with the GRASS plugin

A note from Sam in the Linfiniti team:

The last two weeks of FOSS GIS training courses (posted about here) have been impressive.  High-five to the trainers, Tim and Gavin, for their hard work!  Having only being at Linfiniti for a short time, I was assisting with the courses but also learning some things about the software myself.  This is just one of the nice things I learnt from the QGIS course.

Using the GRASS plugin in QGIS opens you to a whole host of new tools. The plugin makes GRASS more accessible, and simplifies the complexity of GRASS datasets, so that more users will be able to benefit from the GRASS functionality available.

You can convert vector contour lines to a raster DEM, and then visualise the DEM in 3D. The steps below are written for newbies (like I was!), so skip the detail if you an experienced user ;)

1. Setting up your mapset and adding your data

When the GRASS plugin is enabled in QGIS, you will get a GRASS toolbar added. Open your contour shapefile in QGIS as you usually would, then click New mapset on the GRASS plugin toolbar. For those new to GRASS mapsets, here are some guidelines:

  • specify the directory (you can make a 'grass' folder in your home directory - it is important you have full read/write access)
  • create a new location - think of this as a project folder based on a certain location (geographical extent)
  • assign the projection of your dataset (your projection will be fixed for the location and mapset)
  • under the default GRASS region section, click the 'Set current QGIS extent' button
  • enter the mapset name (this will be your username - each user can have a mapset in the location, the 'project folder')

Once you've setup, you will see a red outline around the data in your QGIS view, this is your mapset extents.

Click the GRASS tools icon on the toolbar, and find the option to import your vector or raster.  Here's the vector import:

image0

Once you click the function, select the layer to add (the list will show those layers open in QGIS), type a name and click run.

You will also need to add the newly created grass layer to your QGIS view - this will make it accessible for subsequent grass functions.  Add the layer by clicking 'view output' after running the function, or in the browser tab in the GRASS tools dialog - click refresh, find the file and click the add icon.

2. Creating a DEM from contours

Now for the interesting bits.  Make sure your vector contour from your grass mapset is open.  Under the Module list in the GRASS tools dialog, find and run these functions in this order:

  • *v.to.rast.attr* -> converts your vector to raster based on an attribute (use the height attribute from the contours).  Open your result once its run.
  • *r.surf.contour*-> creates a surface from the rasterized contours.  Tip: edit your mapset region (last icon on the grass toolbar) to adjust the output area to your dataset- this will save time!  Open your result once its run.

image1

3. Visualisation in 3D using nviz

In the modules list, find *nviz*. This can be used to visualise any DEM data, and you can add overlays.  Using a nice colour map as explained in Tim's postwill produce a catching effect.  Running the module, and adjusting the settings (z-exaggeration, lighting, perspective etc) will give you a dynamic 3D view of your data.  Nviz is also apparently capable of 3D fly-throughs for those interested in exploring a bit more.

image2

Voila, and there you go!  And this was all created from the comfort of your QGIS environment, thanks to the awesome plugins that have been added! :)

Hope this helps, and if you've got any questions, feel free to leave a comment!

-Sam

A nice overview of QGIS for MapInfo users

Just a quick link to share: Its been many years since I used MapInfo but it seems it still has an active user community. Nathan has writtena nice overview of QGIS for MapInfo users - an enjoyable read even if you don't use MapInfo!

Some geek eyecandy

We and our clients regularly work with very large spatial datasets. One of the servers I set up for a client gives this when I run du:

Filesystem            Size  Used Avail Use% Mounted on
/dev/sdd1              14T   11T  2.1T  84% /mnt/storage
/dev/sdc1              14T  143M   13T   1% /mnt/storage2

With apologies to non-geeks who don't see the point of the above :-P For those interested in setting up large filesystems, you may be interested to know that we are using ext4 on both storage arrays. We are using one massive partition on each, and so far the filesystems have been extremely reliable. In order to create such a large partition just be sure to use parted (or gparted for you point & clickers) and use GPT for the partition table.

Something for my Xmas wish list...

New QGIS 1.6 Brochure available

The fine folks in the QGIS Community Team have produced a great looking update to the QGIS Brochure. The community team is comprised mainly of non-developers but makes a massive contribution to the project since they orchestrate the web sites, user manual production (in multiple languages), brochures and many more things that make QGIS visible and accessible to the world at large.  The brochure is an important part of our publicity profile - it can be printed on double sided paper and distributed at shows and conferences, making it easy to put pertinent info about our project into an interested person's hand. The Community Team is always looking for new volunteers, so if you always thought "I'd like to help but I can't program", now is the time to get involved!

The new QGIS 1.6 Brochure

A workflow for creating beautiful relief shaded dems using GDAL

Sometimes I create hillshades using the QGIS hillshade plugin and then overlay the original DEM over it. I set the DEM to have a false colour pallette and set it to be semi-transparent to produce something like this:

Typical usage of a hillshade with false colour overlay

That is all well and good but a bit impractical. It would be much nice to have the colour pallette permanetly assigned to the hillshade. Also I want to be able to clip and mask the resulting raster to the boundary specified in a shapefile. Fortunately, GDAL provides all the tools you need to make this happen. There are already some nice articles (like this one) that describe parts of this workflow but I am writing this because I wanted to note the additional steps that I took to make this work well for me.

Before you begin

Before you begin you should have:

  1. a raster containing digital elevation data (DEM) - in my case its called 'alt.tif'
  2. a vector layer (typically a shapefile) containing the area of interest for your final product - in my case its called 'tanzania.shp'

Create the hillshade image

The first thing we need to do is generate a hillshade. There is a nice python plugin for doing this in QGIS, you can do it in GRASS using the QGIS-GRASS plugin. But in this article I'm going for an all-GDAL approach so we will be using the handy **gdaldem** command line application.  I won't be explaining the parameters I have used here as they are well explained in the gdaldem manual pages.

So to create our hillshade we do something like this:

::
gdaldem hillshade alt.tif shade.tif -z 5 -s 111120 -az 90

Which will produce something like this: colorbrewer would be a good place to start if you want to learn more.  Another favourite site of mine is colourlovers.com and for this tutorial I decided to use a pallette from there to see how it would turn out.

Once you have selected a suitable colour pallette (around 5 or 6 colour classes should do it), the next thing you need to do is get some information about the range of values contained in your DEM. Once again you can easily point and click your way to this in QGIS, but here is the way to get it in gdal from the command line:

::
gdalinfo -mm alt.tif

The resulting output includes the computed min/max for Band 1 - which is what we are after:

::
Band 1 Block=1334x3 Type=UInt16, ColorInterp=Gray
Computed Min/Max=1.000,5768.000 NoData Value=65535

Ok so our minimum height is 1m and maximum is 5768m - Tanzania is the home of Kilimanjaro after all! So lets split that range up into 5 classes to match the 'Landcarpet Europe' colourlover pallette I selected. I set nearly white as an additional colour for the highest altitude range.

::
65535 255 255 255 5800 254 254 254 3000 121 117 10 1500 151 106 47 800 127 166 122 500 213 213 149 1 218 179 122

The value in the first column is the base of the scale range. The subsequent values are RGB triplets for that range. I saved this as a text file called 'ramp.txt' in the same directory as my 'alt.tiff' dataset. You will notice that I made the value ranges closer together at lower altitudes and wider appart at higher altitudes. You may want to experiment a little to get pleasing results - especially if you have a relatively small number of high lying terrain pixels and the rest confined to lower lying areas.

Also note that I assigned the highest terrain 'nearly white' so that I could reserve white (RGB: 255 255 255) for the nodata value (65535) in this dataset. We will use the fact that white is only used for nodata to our advantage when we do a clip further on in these instructions.

Ok now we can use gdaldem to generate the terrain map:

::
gdaldem color-relief alt.tif ramp.txt relief.tif

This is what my relief map looked like:

The terrain colour map I produced

Don't worry about the fact that it does not resemble the colour pallette you have chosen - it will do in the next step!

Merging the two rasters

The next step is to combine the two products. I used Frank Warmerdam's handy hsv_merge.py script for this purpose.

::
./hsv_merge.py relief.tif shade.tif colour_shade.tif

Which produced this:

The result of merging my hillshade and my terrain colour map

You may have noticed that it is only at this point that the colours of our product resemble the original pallette we used.

One little gotcha with the hsv_merge.py script is that it throws away our nodata values, so what was sea before (and nodata in my original alt.tif dataset) is now white (RGB: 255 255 255).

Clipping and masking

You may have everything you need from the above steps. Alternatively you can also clip and mask the dataset using a shapefile.

::
gdalwarp -co compress=deflate -dstnodata 255 -cutline Tanzania.shp
colour_shade.tif colour_shade_clipped.tif

My final image is now a compressed tif with nodata outside of the country of Tanzania and looks like this:

Final result: A false coloured elevation map for Tanzania

A final note

One of the things I love about the command line is the repeatable and reusable workflows it allows for. I can distill everything in this blog post into a sequence of commands and replay them any time. If you are still stuck doing things in a GUI only way, give BASH a try - you can really do powerful geospatial data processing with it!

Vector layer styles, 24bit pngs and theming in OpenLayers

I wanted to take a moment to mention three handy little tips for OpenLayers. First lets look at a typical map OpenLayers project:

A typical OpenLayers project

Tip #1: If you want OL to pull down 24bit png images instead of the default 8 bit dithered images, you can append  ';mode=24bit' to the format option for a WMS layer e.g.

var imagery = new OpenLayers.Layer.WMS(
 "my_layer",
 "http://localhost/cgi-bin/mapserv?map=/home/web/mapserver-tut/mapfiles/world.map",
 {layers: "Country,Cities", format: "image/png; mode=24bit"});

Of course there is a trade off of image size for image quality, but the 24bit pngs I use in my map look clean, anti-aliased and without artifacts.

Tip #2:Bored of the default OpenLayers widgets theme? Run, don't walk to the mapbox OpenLayers theme page and get your OpenLayers map controls looking gorgeous!

Tip #3:None of the examples on the OpenLayers website show how to do a simple thing: set the colour and style for all features in an OpenLayers vector layer. They all focus on creating class breaks and doing more advanced things and don't mention how to get the basics done. Here is how you make all the features in a given layer have the same appearance:

var myLayerStyle = OpenLayers.Util.extend({},
 OpenLayers.Feature.Vector.style['default']);
 myLayerStyle.fillOpacity = 0;
 myLayerStyle.graphicOpacity = 1;
 myLayerStyle.strokeColor="red";
 myLayerStyle.strokeWidth=1;
 stylemap1 = new OpenLayers.StyleMap(myLayerStyle);
 var format = new OpenLayers.Format.GeoJSON();
 var layer = new OpenLayers.Layer.Vector("Areas", {styleMap : stylemap1});
 var feature = format.read({"type":"Polygon",
 "coordinates":[[[21,-31],[23,-29],[24, -31], [22,-32],[21,-31]]]})[0];
 layer.addFeatures(feature);
 map.addLayer(layer);

In the above example I clone the standard style for a new vector layer (you know, that good old orange!) and then override some of its properties to make it a red stroked non-opague stule.  The layer style is then included in a StyleMap with only one element (as opposed to multi-element StyleMaps used for unique value renderers). Finally, when the new layer is created, our StyleMap is added to it.

Lets take a look at how our map looks with the above tips applied (click for larger version)!

All our tips applied to our project

The OpenLayers guys have built an incredible piece of software - everyday I find something new and cool that I never thought it could do before. Hope you enjoyed the tips!

Another QGIS case study

We had another case study submitted to the QGIS website this week - take a read for yet another interesting application of our favourite FOSS GIS software!

Mapserver + OpenLayers + Django == This weeks training course

This week we are rounding out our busy year of FOSSGIS training activities with a week course on using Mapserver, OpenLayers and Django. On Monday we covered Mapserver and the particpants were quickly able to produce good looking WMS services by building their maps in QGIS and exporting them to Mapserver .map files. Today it was the turn of OpenLayers and we loosely followed the great OpenGeo Openlayers Training Course. It was a departure for me to use someone else's training notes since I normally write my own. I probably will return to using my own course notes always since the OpenGeo notes were in some places too complex for what I needed to show and occasionally had issues with example urls not working for web services etc. That said I am very grateful to the OpenGeo folk for making their notes available - I learned a few things myself along the way.

Our course attendees (only four people this time around which makes it nice and personal)  seem to be learning a lot and enjoying themselves. One thing I love about FOSSGIS and Linux is how easy it is to get all the software installed and running. Bochengedu, one of our attendees (from Botswana) didnt have Ubuntu on his laptop as required for the course.  So in between lecturing yesterday I installed vmware player, ubuntu 9.10 into the VM (it was the only i386 iso I had handy), set up PostgreSQL / PostGIS / QGIS / Mapserver etc.  - all in only a few minutes of my time. Try doing the same thing setting up e.g. Windows + Oracle Spatial + ArcServer etc....I'm sure it would be a challenge.

I'll post the revised django course notes and the notes I made for the mapserver part of the course here some time next week. Can't wait to dive into django with the participants tomorrow - its always a pleasure to show it to people!

FOSSGIS Developer Training in progress!

QGIS 1.6 'Copiapó' is released

We just announced the release of QGIS 1.6. Another release is done and we are already hard at work on the next version!

Copiapó splash screen

MapBox - stunning maps made with FOSSGIS

I love a good map, so it was a nice suprise to stumble apon the MapBox project via a hint from Dane Springmeyer over on #qgis channel. They are rendering some beautiful maps, with a strong emphasis on aiding society with their work, and all created using FOSSGIS.

Some of the MapBox products

Python QGIS Cookbook

Its probably not widely know yet, but Martin Dobias (QGIS hacker who brought you many nice things including new symbology, python bindings, new labelling tool and the upcoming multi-threading renderer implementation) has been building up a very nice PyQGIS cookbook. The cookbook gives a very nice introduction into programming with the QGIS python api (it's really easy, try it!).  Other people have also been contributing to it and it would be great to get more examples, so if you have some nice tips / articles, checkout the cookbook sources here:

svn co http://svn.osgeo.org/qgis/docs/trunk/english_us/developer_cookbook

I've rendered out a PDF version of the  PyQGIS Cookbook (click to download) in its current state, hopefully someone will find it useful.

QGIS & PostGIS Training at AIMS

This week we (Gavin Fleming, Sam Lee Pan and myself) are doing more training - a week of QGIS and PostGIS. Its a small group this time and they have GIS knowledge already so we get to go much deeper into the nuts & bolts of QGIS than I normally would do on a course (which is a real pleasure for me). Our attendees are a mix of people from industry, government and students - and we have one attendee from Botswana!

Also very interesting is the venue we are using to run the course in. AIMS (African Institute for Mathematical Sciences) is situated a stone's throw from the popular Muizenberg beach,  Cape Town.  Now this (AIMS) is one awesome place.  When you walk in the door there is a statue of Steven Hawking who paid a visit to the center. And the place is brimming with maths students from all over Africa. They are all on fully paid up scholarships to attend a residential diploma course in mathematics which will prepare them to go on to do masters and Phd courses in maths. So they get a room, full board and access to top notch tutors and leave with excellent skills and a network of friends around Africa with whom they can collaborate in future years. The best part is that the whole center runs on Linux. They have labs full of ubuntu machines where they beat out complicated formulas using SAGE and make python jump through mathematical hoops.

Now the funny thing is that I have been dreaming for the last few years of having just such a center for FOSSGIS - where people from all over Africa can come and do a residential course in using and programming FOSSGIS. So it was with fascination, pleasure and yes, a little bit of envy that I was taken around the AIMS facilities. One day hopefully someone with an unbelievable fortune and no idea what to do with it will see this blog post and contact me so that we can start AIFS (African Institute for FOSSGIS Studies) :-).  We are really grateful to AIMS for hosting us this week in their excellent facility, and showing us what a little foresight and ingenuity can achieve.

I'll leave you with a couple of pics of our course attendees doing their thing...

[gallery link="file" columns="2"]

A summary of activities at the QGIS hackfest in Wroclaw, Poland, Nov. 2010

Its been an exceptional time - just like every hackfest I have attended. We have had 29 participants (28 humans, 1 dog) all donating four days of their time to make QGIS better. There have been many stimulating discussions, hundreds of svn commits and demonstrations of cool new features and ideas that will eventually make their way into the QGIS you use on your desktop. The hackfest is being held at the Department of Climatology and Atmosphere Protection with Paweł Netzel acting as the local organiser, along with Milena Nowotarska, Robert Szczepanek, Maciej Sieczka and Borys Jurgiel.

Along with the other attendees of the hackfest, let me express our heartfelt thanks the Pawel, Milena, Borys, Robert, Maciej, the Dept. of Climatology and all the  local folks who worked so hard to host the event - we are extremely grateful!

Plugins

We had a detailed discussion about plugins, spearheaded by Borys Jurgiel and Martin Dobias. The plan is to carry out a complete overhaul of plugin management including the way plugins are registered in the repository, how they are listed and managed in the user interface, and what metadata and other properties should be associated with a plugin.

Threading Branch

Martin Dobias demonstrated the work he is doing in the threading branch. The threading branch is a result of his Google Summer of Code project and introduces multi-threaded rendering of the canvas to improve the speed with which a given scene is rendered. It also adds various other improvments to try to boost general performance of QGIS.

Graphical User Interface

We had an extended discussion about the user interface and tried to identify cross cutting issues that can be improved and also to identify specific issues with individual dialogs.  One of the goals is to make QGIS usable on small screen devices such as netbooks. You can already see the result of some of the revisions we have made in svn.

Updates to the vector dialog box (in progress)

3D Globe

One of the highlights of the hackfest has been Pirmin Kalberer's demonstration of the work he has been doing to implement a 3D globe within QGIS. The globe links directly to the QGIS canvas - whatever vector or raster lines that are present in QGIS will be displayed in the Gobe.  See my previous post for a little video of his presentation. The globe can also produce true 3D visualisations with the help of a pair of 3D glasses.

Data driven labelling

Marco has been working on improvements to the support for data driven labelling in QGIS. With the work he is doing, you can add label x,y position fields to your attribute table. When you label the layer with the new generation labelling tool, the labels will be placed at the positions indicated by the x,y positions in the attribute tabel if present, or otherwise autopositioned by the labelling tool. The cool part is that you can interactively move the labels and their new position is written to the x,y fields so that they are automatically placed at that position in future.

Attribute management

Juergen Fischer has been working on improved support for management of attributes. For cases when you are merging multiple features together, you will be able to select which attribute from the merged features you wish to keep for each field. He has also been adding an option to use attributes defaults so that when you capture a new feature it's attributes are defaulted to the last feature you captured.

Snapping Support

Cédric Mori has been working on making the snapping tools more accessible when digitising. His patch (now in svn) moves the snapping options dialog from the project properties dialog into a dock window for easy access while digitising.

PostGIS Versioning

Horst Duester has been working on his PostGIS versioning plugin which adds SVN like capabilities to editing of PostGIS datasets. With the plugin you can have multiple concurrent editors of a given PostGIS dataset and it will allow changes to be checked in and conflicts to be resolved in the process if neccessary. The plugin is available from the plugin manager via the 3rd party repositories.

Manual updates

Anne Ghisla and Otto Dassau have beenn working to update the manual include the new features in the soon to be announced QGIS 1.6.

QGIS Certification

We had a discussion about the idea of creating a certification programme for QGIS. The idea would be to create standards for people giving and receiving training in QGIS and a centralised certification programme so that, for example, a user receiving training in Poland will cover a similar curriculum and receive a similar quality of training  to one undergoing training in South Africa.

Python Plugin Workshops

Some training was provided for new developers to introduce them to plugin programming and stimulate the addition of new contributors to the project.

Offline Editing

Mathias Walker worked on the offline editing tool that was recently added to trunk. The offline editor lets you take your PostGIS dataset 'on the road', make edits and then synchronise your changes back into the original dataset when you return to your desk.

Using GIT

We had some interesting discussions about using GIT version control within the project. Pirmin Kalberer gave an interesting talk on how to use GIT and how to  use GIT together with SVN. Some of us will probably start using GIT for our personal code management although we don't plan to do any official migration from SVN to GIT at this stage.

PostGIS management plugins

There are a number of PostGIS plugins in the plugin repository - some of which have overlapping functionality. A discussion was held and plans are afoot to merge these where appropriate and also add a new menu to QGIS - 'databases' which will provide a centralised location for database related tools.

GRASS

Paolo Cavallini and Giuseppe Sucameli have been working to clean up the GRASS modules list and generally tidy up the GUI components of QGIS - GRASS integration.

Thats not all...

The workshop is not over and I am looking forward to spending the remainder of it with my QGIS buddies who all are doing such great work to make QGIS better than ever.

Gallery from the QGIS Hackfest - Wroclaw 2010

[gallery link="file"]

Cumulative downloads for QGIS - Nov 2010

Ok so Martin complained that the last chart I made of QGIS downloads looked a bit downbeat and that I should rather show it as a cumulative total...so here we go...

Cumulative downloads for QGIS November 2010

3D Globe In QGIS - demo at Wroclaw Hackfest


Presentation by Pirmin Kalberer on the work he has been doing to integrate 3D globe support into QGIS.

For the impatient, the plugin requires Martin's threading branch to be integrated into trunk and ideally needs on the fly reporojection support in order to deal with projected rasters (which Radim Blazek has been looking at).

Update of QGIS Download stats

FOSS GIS presentation at Cape Tech

Things have been busy – I just back from training course in Tanzania, and last week I was giving a lecture and practical at the Cape Peninsula University of Technology. Lecturer Kevin Musungu from the Civil Engineering and Surveying Department at Cape Technikon asked us to give a presentation on open source GIS after meeting Tim at the QGIS workshop earlier this year. We were happy to introduce them to open source GIS and QGIS as they had currently had no exposure to this side and relied heavily on propriety GIS software. The Head of Department also came to sit in the lecture and had some good questions regarding open source as an alternative.

The class were third-year BTech surveying students that were doing a course in GIS. Some of them are already involved in the working environment, such as the SA governmental Department of Rural Development and Land Affairs. Another visiting attendee was planning to put GIS into a practical, live project to assist his community.

The lecture started off with an introduction to the FOSS movement, with some background on how it started. We then went onto open source GIS, along with a few case studies of open source GIS. This included the Department of Land Affair's Introduction to GIS resources, mention of theOpenModeller project and AFIS project. Then I went onto QGIS, introducing the software and some of the features, along with a demo.

Talking about free & open source GIS

Later that week, we followed up with a practical using QGIS and showing how it could achieve the same results that they did their practical test in ArcGIS. Added to that the students were all given discs to take home (thank you to Kevin for organising this) and will be able to use QGIS at home.

I explained to them the different ways on how to get help: through the user manuals, wiki's, forums, IRC and mailing lists. Feedback from the class was good One of the students commented on the user friendliness of the interface and another was interested in doing an internship on open source GIS technology.

Students using QGIS:

image1

` <..//images/2010/11/IMG_6471_resized.jpg>`__image2

` <http://linfiniti.com//images/2010/11/DSC01711_resized.jpg>`__image3

` <http://linfiniti.com//images/2010/11/DSC01709_resized.jpg>`__image4

image5

Back to Top

Sustaining Members