View here on youtube: https://www.youtube.com/watch?v=0pDBuSbQ02o
View here on youtube: https://www.youtube.com/watch?v=oOhbbEkl4Kg
Continuing on from part 1, another feature I’ve recently pushed to QGIS is the ability to control the hue, saturation and colour of a raster layer. This builds off the excellent work done by Alexander Bruy (who added brightness and contrast controls for raster layers), and it’s another step in my ongoing quest to cut down the amount of map design tweaking required outside of QGIS. Let’s step through these new features and see what will be available when version 2.0 is released in June…
First up is the ability to tweak the saturation of a layer. Saturation basically refers to the intensity of a colour, with low saturation resulting in a more washed out, greyer image, and high saturation resulting in more vibrant and colourful images. Here’s a WMS layer showing an aerial view of Victoria at its driest, least appealing and most bushfire ready state:
Let’s tweak the saturation a bit to see if we can make it more appealing. In the Style tab under raster layer properties, you’ll see a new “Saturation and hue” section. For this layer I’ll bump the saturation up from its default value of zero:
Which results in something like this:
Ah, much better. This actually looks like somewhere I’d like to live. A bit over-the-top perhaps, but it IS handy to make quick adjustments to raster colours in this way without the need for any external programs.
How about turning an image grayscale? I regularly have to do this with street directory basemaps, and until now couldn’t find a satisfactory way of doing this in QGIS. Previously I’ve tried using various command line utilities, but never found one which could turn an image grayscale without losing embedded georeferencing tags. (I did manage to achieve it once in QGIS using a convoluted approach involving the raster calculator and some other steps I’ve thankfully forgotten.)
But now, you can forget about all that frustration and quickly turn a raster grayscale by using a control right inside the layer properties! You even get a choice of desaturation methods, including lightness, luminosity or average. Best part about this is you can then right click on the layer to save the altered version out to a full-resolution georeferenced image.
Lastly, there’s the colourise option. As expected, this behaves in a similar fashion to the colourise tools in GIMP and Photoshop. It allows you to tint a layer to a specified colour. Let’s take a WMS layer of Melbourne, tweak the brightness and contrast, and colourise it blue…
These changes are just a tiny, tiny part of what QGIS 2.0 has to offer. It’s looking to be a sensational release and I can’t wait for final version in June!
The latest version of Print composer features new
Rulers and guide lines or “alignments”
Rulers are a well-known feature in graphics programs such as Gimp and Photoshop. Now you can also find them in QGIS Print Composer. Click onto the ruler, hold the mouse key down and move the cursor to position guide lines for map feature alignment.
Of course, there’s also the handy “Snap to grid” functionality.
This fifth part in my series on QGIS 2.0 Print Composer presents
There are numerous different options for map grids in the new composer but a picture is worth a thousand words:
The upper-left map features a zebra frame style and coordinate labels aligned horizontally and vertically.
The upper-right map shows a normal frame with labels written inside the frame instead of outside. This grid shows an additional offset.
The lower-left map has no frame but customized, colored and dashed grid lines.
Finally, the lower-right map shows a cross grid with default horizontal coordinate labels.
I’ve just pushed my first major contribution to QGIS — the ability to set the compositing mode for a layer. Compositing is a technique widely used by cartographers and graphic artists to fine tune how layers are blended together, and it allows for some spectacular results! Until now, the only way to get these effects would be to export a map to a separate editor like Photoshop or GIMP and playing with the layer modes there. But with QGIS 2.0, blending can be controlled via a simple drop down menu for both raster and vector layers:
So what makes this so great? Well, in previous versions the only option for compositing layers in QGIS was by setting a layer’s opacity. This approach has some limitations. Let’s say you want to overlay two raster layers – a basemap layer and a heatmap. You could place the heatmap layer over the basemap and set its transparency at 50% so that the basemap shows through, but then both the basemap and heatmap layers will be partially faded out:
With QGIS 2.0, you’ll be able to use the “multiply” blend mode to overlay these layers. This means both the heatmap and underlying basemap will be shown with full intensity:
Ok… perhaps that’s not the prettiest example, but it is something I have to do a lot in my job. Until now it’s only been possible by exporting the map to GIMP or Photoshop/Illustrator and setting the blend modes there. That’s always fiddly, time consuming and generally frustrating all round. Much easier to just change it with a dropdown within QGIS itself.
Let’s move on to some more impressive example. First, here’s a terrain map using a combination of a landcover thematic with ‘overlay’ blending and a hillshade set to ‘multiply‘ blending. The graticule lines are also set to overlay – note how they aren’t visible over the lighter water areas and brighter hillshade regions.
Ok, that’s nice, but let’s try something a little different. Using a combination of darken, screen, hard light and overlay:
These a just some rough examples — I’m keen to see what results others get using this feature (feel free to post links to your work in the comments).
One final note: I’m really appreciative of the efforts of the QGIS dev team, who’ve been really supportive and helpful while I find my way around the QGIS codebase. A big thank you has to go to Nathan Woodrow for taking the time to review this commit and answering all the questions I’ve had!
I am a big fan Scott Hanselman and this post was inspired by his 2011 Ultimate Developer and Power Users Tool List for Windows with some extra stuff thrown in. I have nowhere close to the amount of tools that Scott does but I thought it would be cool to share my setup anyway.
Sublime Text 2\Notepad++ : These two text editors are the best of the bunch. Sublime Text 2 has a nice simple interface, good text editing features, and simple to configure. Sublime doesn't fill every need so Notepad++ fills any gaps.
Visual Studio 2010 : I'm mostly a C++ and Python guy now due to QGIS but every now and then I need to do some C#.
Qt Creator : If you are working with Qt and C++ this is the IDE for it. Built in Qt help files, form designer, good editor (good for someone who can't use vim). Qt Creator is like Visual Studio for Qt C++ but less...bloated.
Aptanta Studio 3 : Since starting Python I have tried a bunch of editors and have settled on Aptanta Studio 3 for now. I find it works constantly, has some nice IDE features, built in unit test runners, and is FREE. If I'm working on a single Python file I will normally use Sublime Text 2 but anything project based like QMap or a QGIS plugin will be done in here.
git : Everyone uses git and if you don't you should.
svn : -_- Ok it was good at the time, but see above.
ConEmu : I bloody love this program. If you are still using cmd.exe to do anything just stop now! Go and download this. Tabs, better copy and paste, resize-able window, predefined tasks, and heaps more. Trust me you will be more productive. I found it though one of Scott's posts and haven't stopped using it since.
QGIS : Obviously
ILWIS : I first used this when I did a bushfire project ( the second round was done in QGIS ) however while I don't use it much anymore it still has some cool ideas.
PostGIS : Great relational spatial database
SQL Server 2008\2012 Express : It's not that bad. 2012 has better spatial support. QGIS supports 2008/2012.
Bins : This is a nifty little tool that I found tonight. Lets you group icons into "Bins" in the Windows taskbar so you don't end up with mess of icons. Handy! Not free but only $5
Fences : Another one from Scott's blog. Handy for sorting out your mess of a desktop.
Greenshot : Great for taking screens shots. Export to Paint, Dropbox, Imgur, file, clipboard, printer. Built-in image editor for annotations. And it's free.
Dropbox : It always pains me to hear people say "oh my computer crashed and I lost all my documents", and if it's your sister in law two days before an assignment is due then it's even worse. Use Dropbox, or SkyDrive, or something but keep more then one copy of important stuff.
Expression Encoder 4 : I have plans to do some screencasting in the future so I am giving this a run to see how things work out. This has a ten minute limit on the free version, but you don't really want to hear me talking for more then ten minutes anyway.
Total Commander : This is one of the best tools you can get for working with your file system. No drag and drop here. Full keyboard control and speed. Can take a bit to getting used to however it will increase your productivity.
UtlraMon : I can't even work with one screen anymore and this tool helps you get the most out of your monitors. Multi screen taskbar, shortcuts for predefined window locations and more.
Skype : I don't really use Skype a lot but when I have it always works well. Anytime I have to be away from the family in the future I plan on calling using Skype.
Irssi : Good ol' IRC. I have played around with a whole bunch of IRC clients on Windows and Linux but never found one that I liked apart from Irssi. Sure it runs in a console window but IRC is just text anyway so who cares. I like to tweak things so Irssi scratches that itch for me. NathanW on #qgis.
Trello : Another one in the bloody love list. A simple to use but powerful, well I don't really know how to describe it so you can just check it out. I use it for personal task management, work projects, software projects, event planning.
GitHub : I really like GitHub it really does add a nice social experience to development that most sites fail on.
gis.stackexchange.com : Personally I really think they hit the nail on the head when building this Q&A site. I try to spend as much time as I can on here answering QGIS questions.
If anyone has anything extra they can recommend feel free to leave a comment.
Today’s spotlight is on a feature which you’ll really love if you have to arrange a little more text on a print layout:
Regular labels are limited to one font, size and color. With the new “Render as HTML” option, you gain flexibility to use HTML tags to style your text by adding headers, lists and even images (note the QGIS logo I added by pointing to the image online):
After guide lines and multi-column legends, today’s focus is on
Small overview maps are used to help the reader get an idea of where the region displayed on the main map is located. In the new Print Composer, it’s simple to add such overviews: Add the main map as usual. Then add another map object to the composition an go to the “Overview” section. There, you can specify that the second map object should be an overview map for the first one: Just specify “Map 0″ in the dropdown list:
The Script Runner plugin allows you to manage and execute a collection of scripts in QGIS to automate tasks and perform custom processing.
Version 0.6 of Script Runner has been released and includes these changes:
- Arguments can be passed to a script using keyword arguments
- Script output is logged to the Script Runner window
- Script output can be logged to disk
- Preferences dialog allows control of output and logging options
- Exceptions in scripts are displayed without interfering with console/logging output
- Context menu (right-click) to access script functions
- Edit script function uses system default editor or one you specify in preferences
For a basic introduction to Script Runner see this post: Script Runner: A Plugin to Run Python Scripts in QGIS
Working with Scripts
To run a script, you must add it to Script Runner using the
Add Script tool on
the toolbar. Select the script from the file dialog to add it to a list in the left panel. The list of scripts
is persisted between uses of QGIS.
Running a Script
To run a script, select it from your list of scripts and click the
Run tool. Output from the script will be displayed in the Script Runner console
Remove a Script
You can remove a script by selecting it from the list and clicking the
Remove Script tool. This just removes it from the list; it does nothing to the script
file on disk.
Info tool will populate
the Info and Source tabs in the panel on the right. The Info tab contains the
docstring from your module and then a list of the classes, methods, and
functions found in the script. Having a proper docstring at the head of your
script will help you determine the purpose of script.
At version 0.6 the
Info tool is only needed if you have disabled automatic display of info/source (see Preferences).
Viewing the Source
You can view the source of the script on the Source tab. This allows you to quickly confirm that you are using the right script and it does what you think it will.
Version 0.6 implements a number of new features.
Passing Arguments to a Script
You can pass arguments to your script using keywords. Your run_script function must have two arguments:
Running your script is done using the
Run script with arguments tool. This prompts you to enter your argument(s) in a key=value format:
All strings must be quoted and multiple arguments should be separated by a comma.
When your script is run, the arguments are contained in args, which is a Python dict. In the example above, you could access them like this:
Scripts that accept keyword arguments are displayed in the list with two asterisks appended to their name:
See Passing Arguments for a complete example.
Printing messages to the console can be useful for both development and status updates in long running scripts. You can clear the console using the
Clear Console tool. There is also an option in Preferences to clear the console each time a script is run.
Logging to Disk
You can choose to log everything that goes to the output console to disk. Use the Preferences dialog to setup the directory where the scriptrunner.log will be written.
Editing a Script
You can open the selected script in an external editor by right-clicking on it and choosing
Edit script in external editor from the popup menu. The default system editor for .py files will be used to open the script. In Preferences, you can specify a different editor by entering the full path to the executable.
The Preferences dialog allows you to set the following options:
Here are three script examples: a simple script that has only a run_script function, one that uses a Python class, and one that passes keyword arguments.
This simple script contains only a run_script function:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
When executed by Script Runner, the script removes any layers currently
on the map, then loads the
world_borders shapefile, sets its fill color to
red, and updates the map canvas and the legend. The
run_script function does all the work. You could expand this script by
adding additional functions that are called from run_script.
A Script with a Class
This script uses a class that is initialized from the run_script function to load some layers:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
In this example, the run_script function creates an instance (
ldr) of a
class named Loader that is defined in the same source file. It then calls a
method in the Loader class named load_shapefiles to do something
useful—in this case, load all the shapefiles in a specified directory.
This script illustrates passing an argument (a path) to load all shapefiles in a directory:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
Lines 29 and 30 illustrate using the passed argument to print a message to the console and call the method to add the shapefiles to the map.
The script examples are minimalistic—they don’t do error checking in a number of places, such as checking to see if a QgsVectorLayer is valid or if needed arguments were actually passed to the script. Don’t take the scripts as examples of complete, solid code.
Comments on this post are welcome, as are bug reports. The link to the bug tracker for Script Runner can be found in the About box, along with the link to the code repository and my email address.
After yesterday’s first post on guide lines & snapping for user-friendly map element arrangement, we’ll have a look at another great new addition:
In the panel on the right, there is a new section called “Columns”. Here we can create multi-column legend layouts by specifying the desired number of columns. Add some spacing too. It will make the result look more balanced.
By default, Print Composer tries to keep all classes of one layer in one column. You can override this behavior – as I did in this example – by ticking “Split Layers”:
Another useful trick is to use text wrapping for long class labels. This option can be found in the legend’s “Main properties” right at the top of the side panel. In this example, I specified wrap on the pipe “|” symbol and inserted this symbol into the longer class names to force a line break:
This is the first post in a series dedicated solely to Print Composer in QGIS 2.0 which you can already admire in recent nightly builds.
Guide lines & snapping for user-friendly map element arrangement
Arranging map elements has never been easier: Elements can be moved as freely as before but now they will automatically try to align with other elements on the page or the page borders. Additional red guide lines help interpret the snapping behavior.
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable sudo apt-get update sudo apt-get install tinyows
The simplicity is a little bit too much, when it comes to serve multiple WFS-T on the same server. There is only one configuration file, but we want a configuration for each service. There are solutions for that, but I never saw a documentation of the most elegant solution we found. It uses Apache rewrite capabilities to set the
TINYOWS_CONFIG_FILE environment variable according to the called URL:
# URL rewriting RewriteEngine On # Forbid direct access RewriteRule ^/cgi-bin/.*$ - [F] # Rewrite /xxx to /cgi-bin/tinyows with TINYOWS_CONFIG_FILE=/etc/tinyows/xxx.xml RewriteRule ^/(.+)$ /cgi-bin/tinyows [QSA,PT,L,E=TINYOWS_CONFIG_FILE:/etc/tinyows/$1.xml]
This configuration included in a virtual host declaration (wfs.example.com) serves your WFS-T on wfs.example.com/servicename.
A few months back I published an article about the large scale deployment of QGIS and FOSSGIS at the state administration of Vorarlberg, Austria. Shortly after I published the article, they asked for the opportunity to update the article with more details. The article that follows below is that amended version. In 2011, the State... Read more »
We’ll be using Postgis2.0 from UbuntuGIS, which has packages for a number of recent Ubuntu releases. Since Ubuntu precise has libc6 2.14 and Debian wheezy only 2.13 we fall back on Ubuntu oneiric for packages, which also has libc6 2.13.
However Postgis 2.0 in UbuntuGIS depends on a lot of llibraries which were in squeeze but live in wheezy under a higher version. Therefore we’ll install a lot of packages from Debian squeeze. Fortunately the libraries are versioned themselves and thus can be installed along the libraries from Debian wheezy.
Let’s go. Add the Debian squeeze sources:
# SRC="deb http://ftp.ch.debian.org/debian/ wheezy main" # echo "$SRC" >> /etc/apt/sources.list
We’ll also add the security source, in case Debian releases a security update.
# SRC="deb http://ftp.ch.debian.org/debian/ wheezy main" # echo "$SRC" >> /etc/apt/sources.list
You may want to replace ftp.ch.debian.org by a debian mirror nearer to you.
Now add the UbuntuGIS sources:
# SRC="deb http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu oneiric main" # echo "$SRC" > /etc/apt/sources.list.d/ubuntugis.list
Now update and try to install postgis:
# apt-get update # apt-get install postgresql-9.1-postgis
Create your database:
# sudo su # su - postgres $ psql postgres postgres=# CREATE DATABASE your_db OWNER your_preferred_user:
Now add the postgis features to that database:
$ psql -d your_db -f /usr/share/postgresql/9.1/contrib/postgis-2.0/ $ psql -d your_db -f /usr/share/postgresql/9.1/contrib/postgis-2.0/spatial_ref_sys.sql
That should be it. Let’s hope it works.
A final warning: you are mixing multiple distributions here. This can lead to problems. Due to version conflicts upgrading packages can become very difficult.
Tomáš Pospíšek firstname.lastname@example.org
Did you know that there is a version of ColorBrewer that does not require Flash?
This week is my last week at Southern Downs Regional Council. On Monday I'm starting a new job. A QGIS related job. WIN!
I have worked at Southern Downs Regional Council for the last seven years and have been grateful for every year. The people, the work, the experience, has all be excellent. It has been a great seven years and I never imagined that I would be leaving, maybe at the ten year mark, but here it is. Starting at SDRC right out of high school without any skills or knowledge of what GIS is or was I grew to love it very quick. Learning GIS, evidently, lead me to programming. Nothing to crazy at first, some VBA here, some MAPBASIC there, MapInfo added the ability to call .NET dlls so I got into VB.NET, which lead me to C#, QGIS entered about three years ago which started me down the road of C++ and Python. Throw in some GPS surveying, data collection, database stuff, bushfire mapping, planning scheme mapping, floods, and you have yourself a nice skill set that you never expected to learn - hell some early school teacher even told my parents I would never do anything useful because "I only did computers".
So enough with the rambling personal history lesson and more about the new stuff. My new job is a Technical Consultant/QGIS Specialist with Digital Mapping Solutions(DMS), a great - of course they are great why else would I work for them - Australian GIS company. DMS were/are the sponsors of the QGIS MS SQL provider and run QGIS training courses around Australia. My new role will be focused around QGIS and QGIS clients in Australia, although it's not limited to that. I'm really looking forward to promoting, using, and helping other people use QGIS in Australia. I really do think there is a good market for it here, and if the growing interest over the last year is anything to go by I feel it is going to be a really interesting year. Working from home, meeting new people, learning awesome skills, pimping QGIS, what's not to love!
My blog will continue as normal, if not more. Expect to see more QGIS in Australia, hopefully we can get some regular meetups happening.
I do have to give credit to the QGIS team and community. Without the great team and community around QGIS I very much doubt any of this would have happened
Today is Open Data Day 2013. I did’t have much time to hack, but I made a few tweaks to my ‘just for fun’ osm-reporter project to provide average, min and max counts per active day for each user. I also did a bunch of code cleanups under the hood which probably nobody except me... Read more »