The rule based rendering in QGIS has just got a make over to improve in some of the old usability issues it used to have. Most of the improvements are UI related. If you would like to try them out you will need to grab a copy of the latest dev build (qgis-dev in OSGeo4W)

Main improvements include:

Nested rules. If the parent rule evaluates to false none of the child rules are applied. This replaces the priority system in the old dialog.

Disable symbol for rules. Rules with no symbol only act as a check for the child rules e.g nothing is rendered for the rule but child rules still are (unless also disabled).

Drag and Drop rules (multi-selection is supported). Rules can be dragged onto other rules in order to nest them and set up a rendering hierarchy.

Inline editing of rule labels, expressions, scales

Overall tweaks to the dialog

The new rule dialog

As you can see in the screenshot, the rules are now organized in a tree which clearly expresses which rules should be applied and when.

In the example above, all the rules under the Sealed rule will only be applied if that rule is true. The old system would have you managing all rules in one big list and dealing with priorities in order to get the rules to apply right, the new dialog is a major improvement.

And the results! As you can see below, QGIS will only render the colored squares if the Sealed rule is true otherwise it just shows a green line.

The rules applied

The work was sponsored by Ville de Morges, Switzerland and developed by Martin Dobias. Thanks to both of them for these improvements.

Note: As this is a brand new feature there might be some bugs, or things that don’t quite work as expected. If you do find something don’t hesitate to file a bug report at hub.qgis.org so it can be fixed, or at least known about.

Hopefully this tool can be of some use to people, as I know it has been very helpful to me since I made it.

As I’m a pretty heavy QGIS user now, and my work place still stores most, if not all, of our data MapInfo TAB format, one friction point for me using QGIS was having to restyle all the MapInfo layers. If we only had a handful of layer this wouldn’t be such a pain but we have a lot of tables and it would take me months to go though each one manually and style them.

I thought “there has to be some way I can automate this…” and so the MapInfo To QGIS Style Generator (or mapinfoToQgis.py) was born. Knowing that QGIS uses QML (a XML file format) to store it style information, and that MapInfo was able to export a style string for each object, I compared what QGIS generated for its QML using the same symbol I picked in QGIS as I had in MapInfo. Almost a 1 to 1 conversion! Once I worked out how to convert MapInfo point size to QGIS symbol size, and MapInfo colour value to RGB it was just a matter of generating a QML with the correct values.

Long story short, after a bit of clean up and writing a user guide I would like release version 0.1 of the MapInfo To QGIS Style Generator for wider testing.

If you are using MapInfo Font symbols or normal MapInfo 3.0 everything should come across almost exactly. mapinfoToQgis.py will use the same fonts in QGIS as you did in MapInfo and select to the correct symbol size. Although if you are using custom MapInfo 3.0 symbols you will get the default QGIS black square symbol,you can just change it to something better after loading the QML.

Currently the program only support converting symbols but I plan on adding line and region support sometime in the future.

One trend that come up a lot in the poll I recently ran (results will be out soon, just writing a summary blog post) is “Needs more powerful edit tools“. And I agree.

Coming from a MapInfo background nothing much changes when you move to QGIS, MapInfo had the simple Add Point, Add Region, Add Line kind of tools and then you need to use plugins to do anything a bit more advanced (MapCAD). QGIS has the start of a kind of MapCAD thing happening although not as complete.

Why not just let people write plugins?

However I think in order to make QGIS a more attractive package to a lot of people it needs to get some built in semi-advanced to advanced editing tools; getting back to those poll results of “Needs more powerful edit tools”.

I thought to myself “What would I like QGIS to be able to do when it came to editing?” although I came up with a small set my editing needs are only relatively small. I then thought the best way to find out what people need is to just create a blank canvas for people to throw their ideas around on and then go from there.

Why not just create a ticket?

My idea is to get a larger idea of what people need and want rather than just one-off tickets. Although the ideas will be at the edit tool idea level it will be easier to see how they should all fit together if they are all in one place and editable by other people. You can then start asking questions like: Do we really need that UI there? Can we merge these tools? How should the output be handled?

The overall goal is to have a tight, thought out, group of edit tools rather then someone creating a plugin over here for one thing and some else creating something else over there.

So how do we get this going?

Well I have created a Google Document that anyone can edit and view in order to start brainstorming ideas. The link can be found here.

I have already created an example of two ideas that I would like to see.

So go ahead, throw some ideas up. I’m interested to see where this can head.

Why use Google Docs and not the QGIS wiki?

Mainly because Google Docs makes it very easy to do frictionless editing of a document together. No need for user names or passwords or overwriting someone else’s changes (Google Docs is all real time).

I have just whipped up a small user poll for QGIS users. The poll is just to give me (and indirectly the team) some idea of people’s opinions about QGIS and what it could do better. The poll is only short (9 questions) and one of the main things is “What could QGIS do better?”.

All the answers are anonymous so feel free to say what you like about anything. In the end if something isn’t working the way you think it should, write it down. It’s not going to hurt anyone’s feelings :)

If you are a partial QGIS users who mostly uses MapInfo or ESRI stuff I would also like to get your opinion.

Another cool open source project that I have become a part of (as a QGIS packager and tester) is the OSGeo-Live project. The OSGeo-Live project is a live DVD/USB/Virtual Machine built on xUbuntu(striped down Ubuntu linux) that has a lot of cool open source geo spatial programs all set up and ready to use.

The OSGeo-Live project contains:

Browser clients

A small sample of crisis management software

All the popular database engines (PostGIS, SpaitalLite etc)

Pretty much all the open source desktop GIS apps (QGIS, uDig etc)

Open Source GPS navigation apps and globes.

A collection of handy spatial tools

A ready to go web services ready to try in your browser or desktop GIS.

I am, as a heavy QGIS user and a guy-who-tries-to-write-features-and-patches-for-the-code, very happy with this release. I know a lot of people have put a lot of hard work and free time into working on features and bug fixes that keep making this free GIS system even better.

The QGIS team has shifted their source control system to using GIT, which I am very happy about as a lot of the guys on the #qgis IRC channel will know :). The bug tracer has also been moved tohttp://hub.qgis.org/projects/quantum-gis.

Since the release of QGIS 1.6 there have been 1199 commits (using git to count: git log –pretty=oneline upstream/release-1_6_0..upstream/release-1_7_0 | wc -l). Not a bad effort if I may so myself.

If you are still reading this, I really hope it’s because you are waiting for QGIS 1.7 to install.

Turns out the last blog post I did on this subject contained a few errors, mainly that QGIS wouldn’t render the layer when you opened it.

The answer is so obvious it’s almost embarrassing :)

In order to open and display a SQL Server 2008 layer in QGIS correctly, via OGR, you must have a geometry_columns table in your database with the name, geometry type and srid of the layer. That’s it! Oh look, it was even right in front of me in the OGR code for the mssqlspatial driver.

So the process to open a MS SQL 2008 spatial layer in OGR is as follows.

There are two main tables which tell OGR how to read a layers projection:

geometry_columns

spatial_ref_sys

geometry_columns contains the table name and the key for the table spatial_ref_sys which contains the projection string. The projection string is the info that QGIS needs in order to correctly render a layer.

The easiest way to get the correct tables is to let OGR handle it for you via ogr2ogr, then just adding any other tables you may have already in your database to the geometry_columns table.

So to get ogr2ogr to create the right tables for you it’s as simple as running the following command from inside the OSGeo4W shell, changing the connection string part of course:

Uploading even just one table this way will create both tables and fill in the needed info.
The geometry_columns table:

f_table_catalog

f_table_schema

f_table_name

f_geometry_column

geodb

dbo

rivers

ogr_geometry

coord_dimension

srid

geometry_type

2

32768

POLYGON

The spatial_ref_sys table:

srid

auth_name

auth_srid

srtext

proj4text

32768

NULL

NULL

PROJCS[“UTM_Zone_56_Southern_Hemisph….

+proj=utm +zone=56 +south +ellps=GRS80 +units=m +no_defs

So if you have already existing tables in your MS SQL 2008 database that were loaded, via say MapInfo’s EasyLoader, you would just upload one table via ogr2ogr to create the two tables needed by QGIS(using OGR) and then add the other tables to the geometry_columns table. If they are all in the same projection than you are in luck as you will only need to upload one in order to get the right strings in the spatial_ref_sys table, if not just upload a small sample for each projection.

If you see a value in Layer SRS WKT: then chances are it’s set right and QGIS should be able to render it, however if you see: Layer SRS WKT:(unknown) Than chances are QGIS will not render it correctly.

Hopefully this help people use MS SQL 2008 Spatial with QGIS, a important step I think in the world of using QGIS on Windows (especially when you don’t have the freedom to run PostGIS:) ).

I might even do a video tutorial when I get some free time after my exams and my wedding.

If you’re using MapInfo think of thematics + queries but on steroids. Rule based rendering allows you to you set, well, rules on what gets rendered and how. The rules are based on a simple SQL style query language that’s built into QGIS.

Take for example the above screen shot. The screen shot is from a current project I am doing in QGIS to clean up our current stormwater/drainage layer. The layer is a in a bit of a mess at the moment so I needed a way to visualize what I have cleaned up and what I haven’t, so enter QGIS rule based styling.

For example: A pipe that has an upstream and downstream invert and is part of the trunk (main) network is then considered valid (for this situation anyway), so I created the following rule:

We also have little connecting pipes that I don’t want to include in valid trunk as they are only used to connect pits to pipes and are just cosmetic, I have excluded them by adding “Description !=’Drainage Imaginary Pipe’” to the above filter.

Next I wanted to show invalid trunk network pipes (ones without an up or downstream invert), so we just invert the last condition and swap the last AND for a OR:

Finally I want to show pipe direction on all pipes but not the connecting pipes, again as they are just cosmetic:

Description != 'Drainage Imaginary Pipe'

You will also note in the screenshot above that I have a max zoom scales set on the last three rules, this is because when I zoom out all that info becomes overwhelming at that scale and distracts from showing the invalid parts of the main trunk line.

So after all that, the results:

Map rendered using rules

and if I zoom out pass 5,000:

Map rendered when zoomed out pass 5,000

I think you can see how this rule based rendering could be very powerful, in fact I have about four different rule sets I use with the drainage layer to show different things to different people.

and the result is a map window and information printed to the console.

Information from MapInfo callback

I think Python could be a good language to prototype MapInfo based app, or even build a whole app itself. If you do end up making something of it let me know I am quite interested with what people could come up with.

EDIT: If you are having trouble opening MS SQL 2008 in QGIS I will have a blog post coming explaining how to correct it. Or you can read the comments between TheGeoist and I below which will have the answer.

Replacing {serverName} with your server name, if installed on your local machine you can use localhost; {databaseName} with the name of the database with the tables;{tableName} with the table to open; {yourLayerNameHere} with the name you would like the layer to have in the map legend.

After that you should see your MS SQL Spatial table displayed in QGIS, with editing support.

At the moment there is no nice interface in QGIS to open MS SQL tables like there is for PostGIS, although that might be a good plugin project for someone to work on.

Click Download Now for the ERDAS ECW/JP2 SDK Desktop Read-Only, Version 4.1 libs,

Fill out a bit of registration details and click though all the pages (this is the most painful process I have ever had to go though to get some libs for a program, ERDAS should be ashamed that it is such an effort.)

Once you have download ECWJP2SDKSetup_RO_20100920.exe; install it.

Copy all the files from C:\Program Files\ERDAS\ERDAS ECW JPEG2000 Read SDK\bin\vc90\win32 into the bin folder of your OSGeo4W install (default is C:\OSGeo4W\bin)
You can open the OSgeo4W shell and run: copy “C:\Program Files\ERDAS\ERDAS ECW JPEG2000 Read SDK\bin\vc90\win32\*.dll” %OSGEO4W_ROOT%\bin to do the same thing.

Launch osgeo4w-setup.exe, the installer that you used to install qgis-dev, and select gdal-ecw, gdal17-ecw and gdal-mrsid, gdal17-sid under the libs section. Let it install the needed libs and any dependencies.

Open %OSGEO4W_ROOT%\bin and search for qgis-dev.bat; open it with a text editor and add the following line:set GDAL_DRIVER_PATH=”%OSGEO4W_ROOT%”\bin\gdalplugins\1.8I always insert it just after SET OSGEO4W_ROOT=

The above code will load MapInfo and open the property layer into the Qt Widget control, with the result below.

MapInfo map in python Qt based form

So this means you don’t “always” have to write your MapInfo based apps in C# or C++; of course I already knew this as anything that can use OLE and provide a native window handle to MapInfo will work, I just never tried it.

One of the cool things I love about QGIS is finding stuff that you didn’t know it could do, well not just itself but plugins that you didn’t know about.

Today my discovery was in how to generate contour lines from a point layer.

First install the contour plugin for qgis via the plugin installer. Just search for “contour”

Once installed open a vector point layer in QGIS. Make sure the point layer has a field that you can use for elevation.

One I prepared earlier

Then select from the menu: Plugins->Contour->Contour

Fill in the information

Details form (The above setting will generate 0.5m contours)

Press OK

Results

Results from plugin

Profit??

The resulting contours will have a field that contains the label and z value for each contour line, you can then just label or color them how you wish.

Note: There is a bug with QGIS memory layers where the fields don’t show up in dropdown or attribute browsers, a simple fix is just to make the layer editable and then non editable then the fields will be there.

The contour layer is a QGIS memory layer so remember to save it to disk eg a shapefile before you close you will loose your new fancy contour layer.

This afternoon I was having a go at getting our work MapInfo layers to look the same in QGIS as they do in MapInfo. I wanted to do this; 1) So I can print maps from both systems for people and they are a consistent style 2) Would rather use QGIS for every day map work. 3) To see what they compare like. I think it came out pretty good, apart from few symbols that I didn’t get time to finish.

MapInfo vs QGIS

Note that MapInfo has anti-aliasing and transparency turned off, as it makes MapInfo very slow and render any output as bitmaps rather than vectors (poor). Where as QGIS is using both, as it doesn’t suffer from the same problems.

EDIT: To be fair here is both with the best settings turned on. They are pretty much the same, which is a good thing.

A couple of days I found a pretty cool open source project for visualizing the history of version controlled code. The project is called Gource and can be found here: http://code.google.com/p/gource/ On the videos wiki page there are a few videos of other projects that have used gource to generate cool videos of their commit history so I thought I should make one for QGIS.

After downloading and building the latest source for Gource and fetching the current trunk of QGIS following these instructions: http://spatialgalaxy.net/2010/12/27/contributing-to-qgis-using-git/ I ran the following in my terminal on my Ubuntu machine, with my current directory being the download git repo from the above instructions:

Don’t worry I know it looks crazy but it’s really not that bad. I’ll break it down.

–title “Quantum GIS” Well, yeah, adds a title to the project.

–logo images/icons/qgis-icon.png Adds a icon watermark

–hide filenames This hides the filenames of the files being committed . I hide these because it makes it pretty hard to see.

–date-format “%d, %B %Y” Formats the date at the top of the video.

–seconds-per-day 0.15 How many seconds represent a day. The lower this is the fast a day goes by, meaning me commits in less time.

–highlight-all-users Highlights all the users all the time.

–auto-skip-seconds 0.5 If there are no commits for this time it will skip to the next commit.

–file-idle-time 0 How long before the file disappears from the video, 0 means never good for seeing the full file tree.

–stop-at-end Stops the video at the end of all the commits.

-b 000000 The background colour, in this case black.

–output-ppm-stream – Tells gource to output the result ppm stream to STDOUT, which is then piped ( | ) into the ffmpeg

That is a quick overview of some of the gource arguments, running grouce -H in your terminal will print out the full list. I’m not going to go into the ffmpeg arguments because frankly I don’t understand them very well and video isn’t really my thing. I’m sure there are ffmpeg experts that would be able to do it better then what I have.

After running the above commands in my terminal window and letting it do its thing, I had a resulting mp4 file which I then uploaded to YouTube.

Below is the video that I uploaded to YouTube, which took about 5 hours due to my very very slow (read 138kb/s) upload speed. The video is about 8 years of QGIS development in just over 9 minutes.

As it’s a bit hard to see in the video due to the quality, each cluster of files is a directory and the branches show the folder hierarchy.