Here I post my thoughts, QGIS tips and tricks, updates on my QGIS-related work, etc.

Back from jungle

01.11.2009 10:02 ·  Notes  ·  visa, travels

I haven’t written anything for a month, as I just haven’t had enough time, and internet access has been quite limited at times. The most important news is that I’m going to the QGIS Hackfest in Vienna. Actually, the discussion about attending the hackfest started more than 2 months ago at the end of August, but I deliberately did not write anything because there were a lot of problems and ambiguities, especially the question of the visa. It was only this week that everything finally became clear.

The most difficult part was getting a visa from the Austrian embassy. The first thing you need to do is call the embassy or visit them in person to get the list of documents required and make an appointment. The last option is more suitable for Kyiv residents; for the rest, it is better to make a call. Remember that there is a charge for the call (€12) and that you can only pay by VISA or MasterCard, so keep your card details around.

The list of documents is not very long, but for all the documents you need a copy with a translation into German, otherwise, they will not be accepted. I have collected the following documents:

The documents should be submitted one month before the planned date of departure. Of course, you can submit them earlier, but they will only be processed one month before anyway. I went to Kiev, stood in line and handed in the documents. Last week I received a call for an interview and went to Kyiv again…

It turns out that I am a suspicious person for the embassy. I got my passport back in April 2008, but it was “clean” until now (well, I haven’t had much luck travelling). So “clean” passport — one. I’m travelling alone — two. Only for 5 days — three. Four: travelling alone, all alone and and not on a sightseeing tour from some agency. Going to the capital — five (Why? For what? He’s probably a terrorist). I talked to the officer for about 15-20 minutes, and here the letter with the invitation to the hackfest, or rather to the “developers’ meeting” (if it had said hackfest - I would certainly have left without a visa), which I had asked the organisers for in advance, came in very handy. Then I waited almost 4 hours for an answer, but it was worth it - they gave me a visa in the end. For exactly 5 days. Now I am packing my bags.

P.S.: You can read about the upcoming hackfest in Vienna on the wiki. There is also a blog post with a report on the previous one, which took place in Hannover this spring, and an interview with the participants. If I get the chance, I will try to post updates directly from the scene or share my impressions when I get back. And this post can be seen as a teaser :-).

QGIS 1.3 "Mimas"

22.09.2009 07:36 ·  GIS  ·  qgis, release

Less than a month has passed since the release of QGIS 1.2.0 and now… 1.3.0 is available. Pretty fast, huh?

There are not that many changes, mostly bug fixes and minor improvements. There is a tendency to switch to native analysis tools (i.e. not related to GRASS), for example this version includes the “Raster terrain analysis” plugin for terrain analysis.

The announcement, as usual, is available on the official blog.

QGIS 1.2 "Daphnis"

02.09.2009 10:59 ·  GIS  ·  qgis, release

Release. There are a lot of changes, especially in the digitising tools: undo/redo support, history of edits, feature simplification and merging, ability to remove holes in polygons, and many other useful features. And also added support for attribute table field aliases, support for keyboard shortcut customisation, plugin and provider for working with OpenStreetMap… going through all the new features will take a long time.

The so-called visual changelog can be found on the developers’ blog. I haven’t translated the announcements in the wiki into Ukrainian and Russian yet because the official version isn’t ready yet. I think it will be cleaned up by tonight, and then I can start translating.

Building QGIS with MSYS

01.09.2009 08:14 ·  Notes  ·  qgis

I wanted to build QGIS on Windows using MSYS + MinGW. I gathered all the necessary programs and libs, updated the QGIS code from SVN and, armed with the “Coding and compilation guide”, set to work. It took my Sempron almost two evenings to compile the dependencies and QGIS itself. It went well at first, but when I got to avce00, I stuck. That thing would not compile at all, throwing warnings and errors at almost every line. I gave up and grabbed the binaries from OSGeo4W. That did the trick.

And this is the moment. It’s compiled. I run it and… and nothing. QGIS crashes at the beginning of loading. I run it from the console - it crashes again, leaving an “Access violation” message in the terminal. So here I am scratching my head and trying to figure out who to blame: avce00, my two left hands or spots on the sun. There are many reasons for this behaviour. Even developers say that building with MSYS and MinGW is quite a complex process.

I decided to postpone it for now, and in the meantime, I will try to build QGIS with VisualStudio Express. I need it for work.

Updated matplotlib for OSGeo4W

12.08.2009 15:07 ·  GIS  ·  osgeo4w, metplotlib

A new version of matplotlib 0.99 has been released recently, the list of changes can be found here. I have rebuilt the package for OSGeo4W, updated the corresponding wiki page and uploaded the new package to the server.

Statist update

04.08.2009 18:41 ·  GIS  ·  qgis, plugins, statist

I continue to work on the Statist plugin. It’s been a while since I updated the public repository - I’ve been working with my local copy. But today I uploaded a pretty big update.

Among the most notable changes:

There is only one major bug left (there are probably others, but they have not shown up yet) - in some cases, the histogram is displayed in a rather strange, I would say suboptimal, way. I have some ideas about how to fix this and will have to test them.

Enjoy the plugin. If you have any problems and/or feature requests, do not hesitate to email the author :-).

Again about non-ASCII characters in matplotlib

04.08.2009 08:07 ·  Notes  ·  matplotlib, python, tips

A bit more about Cyrillic and other non-ASCII characters in matplotlib. I decided to create a more comprehensive example to show how to output Cyrillic (or any other non-ASCII) characters in different parts of the plot. Actually, there is nothing complex here; you just need to find the time and read the manual, which is quite good, by the way. But as not everyone likes to read manuals… Anyway, here is the code:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from pylab import *
import matplotlib.pyplot as plt
import matplotlib.font_manager as fm

plt.rcParams["text.usetex"] = False
fp = fm.FontProperties(fname="/home/alex/devel/mpl_cyr/CharisSILR.ttf")
plt.text(0.5, 0.5, u"довільний текст", fontproperties=fp)

# create some data to use for the plot
x = arange(0.0, 3.0, 0.01)
y1 = sin(2 * pi * x)
y2 = cos(2 * pi * x)

# the main axes is subplot(111) by default
plot(x, y1, label=u"Синусоїда")
plot(x, y2, label=u"Косинусоїда")
xlabel(u"Підпис вісі X", fontproperties=fp)
ylabel(u"Підпис вісі Y", fontproperties=fp)
title(u"Назва графіка", fontproperties=fp)

Cyrillic and other non-ASCII characters in matplotlib

23.07.2009 17:49 ·  Notes  ·  matplotlib, python, tips

There is a wonderful Python library - matplotlib. It is a plotting library that supports a wide range of plot types and is designed to emulate MATLAB commands and behaviour. The library is easy to learn; to draw a simple plot, you literally need two commands. I have used this library in my Statist plugin for QGIS and in another GIS project. To make installation of matplotlib more convenient for inexperienced users, I recently packaged it for OSGeo4W.

Sometimes, I needed to display non-ASCII (namely Cyrillic) characters on matplotlib plots. And there was a problem: such text was drawn as empty squares. Reading manuals, googling, and asking on the mailing list led to two solutions that I would like to share with you.

Method 1: the almighty TeX

matplotlib can use LaTeX to display both plain text and mathematical symbols. Moreover, a limited subset of TeX and the corresponding parser, fonts, and renderer are built into the library, so for this subset, you do not even need to have a full TeX installation. Unfortunately, this TeX subset only contains mathematical characters and letters of the Greek alphabet. In all other cases, an external LaTeX installation is required. To use LaTeX for text rendering, we should set the option

text.usetex: True

in the rc-file. This can be done either globally, by editing the rc-file once, or as needed at runtime. Below is an example of run-time initialisation:

# -*- coding: utf-8 -*-
from matplotlib import rc

rc("font", {"family": "serif"})
rc("text", usetex=True)
rc("text.latex", unicode=True)
rc("text.latex", preamble="usepackage[utf8]{inputenc}")
rc("text.latex", preamble="usepackage[russian]{babel}")

Now we can output Cyrillic (or any other non-ASCII characters)

xlabel(u"Вісь Х: довжина, см")

The big disadvantage of this method is that the user needs to have LaTeX installed.

Method 2: unicode + fonts

matplotlib uses its own font rendering engine with full Unicode support. Therefore, we can explicitly specify a font that contains the required character sets and render the text using that font. Here is a small example:

# -*- coding: utf-8 -*-

import matplotlib.pyplot as plt
import matplotlib.font_manager as fm

plt.rcParams["text.usetex"] = False
fp = fm.FontProperties(fname="/home/alex/.fonts/academy.ttf")
plt.text(0.5, 0.5, u"кириличний текст", fontproperties=fp)

There is also a disadvantage - the required font may not be available on the target system or may be in a different directory, so the font has to be stored in the same directory as your program. But in my opinion, this is much better than having LaTeX as a dependency.

Personally, I chose the latter option.

Vacations and GIS

08.07.2009 15:32 ·  Notes  ·  spatialite

It’s been a week since I went on “last year’s” holiday. Yes, I managed to get those unused 19 days. But that doesn’t stop my bosses from pestering me with phone calls and even dragging me into the office a few times. But all in all, it is very good.

I have more free time, which I spend not only on holidays but also on interesting and necessary things like plugins for QGIS. I’ve already received some feedback on Statist, and I’m improving it. Also, I have an idea for another plugin, but I don’t know if it will be implemented yet.

I am also involved in a GIS project, or rather, its continuation. I came across a nasty bug in the SpatiaLite provider in QGIS. At least, it seems to me that it is a bug. This has caused some difficulties, and I have to look for workarounds…

By the way, a few days ago, Alessandro Furieri (SpatiaLite author) announced the release of SpatiaLite 2.3.1 and released two new projects:

In my opinion, SQLite-based spatial databases are a real alternative to shapefiles. Although shapefiles are the de-facto standard in GIS today, they are already outdated and do not meet the ever-increasing requirements.

Statist plugin for QGIS

02.07.2009 15:20 ·  GIS  ·  qgis, plugins, statist

I have released my plugin for QGIS — Statist.

It is used to obtain statistical information on the specified field of the vector layer attribute table. Both numeric (integer, real, and date) and text (string) fields are supported. The plugin can work on the whole attribute table as well as on selected features. In addition to displaying basic statistical values, Statist also displays a frequency distribution histogram of the field values.

Statist plugin dialog
Statist plugin dialog

To use Statist, it is necessary to have matplotlib installed (it can be installed via OSGeo4W or downloaded from the project page, as it is used to display the frequency distribution histogram.

The plugin is available from my QGIS plugins repository. Comments, feature requests, and bug reports are welcome. It is best to post them in the bugtracker, but email is fine too.

If someone does not need a frequency distribution histogram and unnecessary dependencies, they can use the “Basic Statistics” tool from fTools (now included in core). After my patch, it has the same functionality as Statist except for the frequency distribution histogram.