New Tool: MapInfo to QGIS style converter


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.

Here is a quick example of the output.

Step 1: Take One MapInfo table.

Step 2: Run it though mapinfoToQgis.py

python mapinfoToQgis.py WaterFittings.Tab WatterFittings.qml -c FittingType --UseMapInfo

Step 3: Load QML file in QGIS

Result from running mapinfoToQGIS.py

Step 4: Get a beer?

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.

The program can be found at https://github.com/NathanW2/MapInfo-to-QGIS-style-generator and more detailed instructions and download link can be found at https://github.com/NathanW2/MapInfo-to-QGIS-style-generator/wiki/Using-MapInfo-to-QGIS-style-generator.

Like I said at the start, hopefully other people will find this tool handy as I know I have.  If you do find it handy let me know, I would love to hear peoples feedback.  Also if you find any bugs let me know in the comments or log a issue on https://github.com/NathanW2/MapInfo-to-QGIS-style-generator/issues

Enjoy :)

Browsers: QGIS vs MapInfo 11


Warning: This post contains small rants! You have been warned.

PBBI have recently released MapInfo 11, the new version has brought one change that I think deserves some attention – even if for the wrong reasons.

MapInfo’s browser window was in need of a very good make over; it didn’t follow normal keyboard conventions, eg holding shift to select rather than ctrl; couldn’t sort via the headers; keyboard navigation was poor; and it looked ugly. PBBI then announced that MapInfo 11 would have a new “improved” browser. I thought “Sweet! About time” and then we got a copy. /sigh

So what’s the problem?

First off it’s slow to resize, this would be due to them using .NET WPF for the new browser (I have never seen a good fast .NET WPF datagrid).

Then we have sorting, which is meant to be the cool new feature. This is not the normal just click on the header to sort the column, no because that would be too easy, you have to right click in the browser, click sort and select the options which then opens a new browser window. um what?

Yes this is a pretty handy feature but no it shouldn’t be the only way to sort, you should have a click on the header kind of sort. This seems to be what people wanted.

Next. No visible scroll progress. When you move the little scroll box on the side the browser waits until you have finished to show you the data. I guess the old browser did this too so why change it!

And finally shift click to select a block of rows doesn’t work, I mean come on this is not a hard thing to do.

Surly you can dock it? Nope!

In the end we have a browser that is pretty much the same as the old one but slower……oh and has alternating row colors.

Overall reaction: Disappointed

Enter QGIS

Now if you are reading this blog you are well aware that I am a huge fan of QGIS, I don’t really make that a secret. So I guess the overall point of this post is to compare the QGIS attribute table (browser) and the new MapInfo 11 one.

Lets run though the same list as MapInfo.

Slow to resize? Nope. Even with a large table open the resize speed doesn’t change.

Header based sorting? Yep. Just click the header and it will sort that column. Multi column sorting is on the to-do list.

Live scrolling (results update as you scroll)? Yep + no lag.

Shift click to select blocks of rows? Sure why not. Or you can hold ctrl to select rows all over the grid.

Docking? Yep and floating so you can put it on a different monitor if you need.

Bonus

The QGIS attribute table has a built-in search/filter box, saves having to run a query and have a new window like in MapInfo if you just want to filter the browser.

The QGIS attribute table (browser)

Extra Bonus
The QGIS browser can even have other UI objects inside the cells. Very bloody handy.

Combo box in browser table.

You can even have a calendar date picker if you want.

Lets review

Feature MapInfo 11 QGIS
Good resize speed. No Yes
Header sorting. Yes [See update] Yes
Multi column sorting. Yes [1] No [2]
Live scrolling. No Yes
Shift click for blocks of rows No Yes
Docking. No[3] Yes

[1] Why does it need to open a new browser window? At least make it an option.
[2] On the to-do list

[3] Yes you can use http://www.pbinsight.com/support/product-downloads/item/windowhelper for this support. It’s a good tool go and download it. I just think it should be built in.

Doesn’t look too good for MapInfo at the moment. QGIS is even accessing the TAB data though ogr. Quick tip: if a free program can access and manage your data faster than you, you are failing.

My work place spends a good deal of money on our annual MapInfo “maintenance” licence, money I would happily send to the QGIS project if I had the choice. Or at least part of it,

Data

Both programs opened a 27000 row .TAB file.

Just for the record I’m not anti-MapInfo. It still has some features that I really like. I just wish they would pick up the game.

Update for 11.03 patch

As promised in my comments this is an update to reflect the new header click sorting in MapInfo Professional 11.03.

The 11.03 patch has added header based sorting, and while the sorting works as expected which is good, there is something a little odd.

What is the typical sort pattern? Left click header, table sorts ascending click again and table sorts descending or vice versa.  Then you normally have any extra sorting stuff in the right-click menu e.g Sort Ascending, Sort Desending, Clear Sort etc.

Go into MapInfo 11.03 left click header, context menu appears 0_o…  I’m not aware of any program that  has ever done that.  A menu on left click is not normal, even crappy ol’ Lotus Notes doesn’t have a menu on left click and Lotus Notes is one really crappy program.

Nuff said.

P.S Don’t talk about your new feature i.e the browser, following normal conventions for browser style windows then do something no one has ever done….and still no shift click block select.

P.P.S I know it may sound like a constant bashing but really something like this should never got passed review. I know UI is hard but come, on a context menu on left click…

MapInfo and QGIS – An overview


Disclaimer: Like all my blog posts, this post is a reflection of my opinions and my opinions only. They do not reflect the opinions of my employer.

Recently I have got more into the open source movement, with my coding and my choice of software.  I tend to try to pick open source software for a couple of reasons, one of the main things is being free but apart from that I try to pick software that I can use to improve my development skills.  Being able to view the code is a big plus for me, being able to change and improve the software myself is an even bigger plus.

My most recent pick has been rediscovering QGIS (Quantum GIS), a free and open source GIS system written [mostly] in C++ using the Qt framework, and extensible by both Python and C++. I first discovered QGIS a couple of years ago, I was impressed but not impressed enough to really get into it. Maybe it was that I was so used to MapInfo I didn’t give it a proper look; or I didn’t really have the data in the right format, as I mainly used MapInfo, and if it couldn’t open and edit MapInfo TAB files I didn’t want to use it; or just lack of time; or whatever the reason. I used it for a day thought “Yep cool” and went back to using MapInfo.

Recently, however, they released QGIS 1.5 [and now QGIS 1.6] which changed the way I looked at the software.

The first thing I noticed was it was a lot faster in regards to map rendering then it used to be, not as fast as MapInfo but still very usable and efforts are being made to improve it even more so.

Styling of the layers has also improved a lot since I first tried it, it now has stack styling for points, lines and regions. Stack styles is something that was introduced in MapInfo 10.5, but unlike MapInfo, QGIS allows you to create a stacked style for each feature class rather than a style override like in MapInfo.  So you have a lot more control with styling in QGIS then you do in MapInfo.

QGIS styling dialogs for lines

and styles applied:

Ok not that pretty but it's a demo image.

Styling in QGIS is also only based on the underlying data of the object, think thematic maps in MapInfo.  I kind of like this, rather than just being able to just style an object you need to think about the data that is stored with an object.  This also stops the style and data getting out of sync.  At times I have seen maps made in MapInfo with no information on the object but  just styled to show different classes.

QGIS supports a large number of formats. It can open and write tab files but just not at the same time, no big deal as you can always use shape or a postgis database then just convert back if needed.

QGIS also has an interesting plugin system, while being able to use C++ and Python, the main app has a plugin installer [a plugin itself] which lets you install plugins from “hosted repositories”.  This makes finding new tools with work with very easy.

Plugin installer. Very very handy.

Composers are basically MapInfo layout windows, they allow you to add maps, legends, text labels, dynamic scale bar. attribute tables.  Composers can be exported to svg, pdf or printed just like layouts and you can have as many composers as you need.

A composer window for QGIS

Labeling options in QGIS are pretty much the same as MapInfo, if not more. You have the ability to use columns from a table that defines information about labels eg colour, X and Y etc if needed.

But one big feature that I really like about QGIS is the info tool. Unlike MapInfos info tool, you can define per table how and what information is displayed for each column and there is no stupid Ctrl+C copy bug.  It’s a bit hard to explain so a picture saves a thousand words:

Defining each how each column should be displayed.

and editing or adding a new feature:

When editing or adding features this dialog is shown.

For me as a developer the one thing that I find great with QGIS is it has a very kind and active developer community, though both IRC and email, and the code is relatively well organized .   I was able to pull down the source code for the latest trunk and have a build running in Ubuntu in under a hour [this mainly being due to my lack of Linux experience].   Being able to see something you don’t like, change it and submit it back to the project is a very good feeling.

Some downsides:

While QGIS is very good, and is always improving, it doesn’t always win over MapInfo in everything.  One major thing that MapInfo has going is its SQL, being able to run the same SQL syntax over any kind of table in MapInfo is a great feature.   QGIS, in this regard, tends to leave those things up to the underlying provider.  You are able to run simple [or complex] queries on an open table but being able to do something like “Select Col1, Col2, Col3 From Table Where Col1 = “SomeCondition” Group By Col2″  isn’t really there, although if you are running PostGIS it is quite easy.

Query

QGIS Query builder.

The next big thing MapInfo has, is MAPBASIC.  While QGIS has a built-in Python shell and has a relatively good API, MAPBASIC is very easy language to get up to speed with especially for beginners.

MapInfo also has multiple map windows, this is something that isn’t currently implemented in QGIS.  However I did bring it up on the #qgis IRC channel and the developers seemed happy with the idea but just needed time and someone to implement it.

Summary:

I could talk all day about all the cool things that QGIS can do but to save boring you I’ll leave it at this for now, more posts to come in the future I’m sure.

At the moment for my current day-to-day map work, I have gone from using MapInfo to using QGIS almost full time.  Like mentioned above, there are still some things that MapInfo does well and I tend to use MapInfo for those kind of jobs.  Also as my employer uses MapInfo and runs pretty much a full MapInfo system, I still use it for maintaining things like Exponare.  Using and developing for QGIS also means I have fallen behind on my MapInfo .Net tools, I still have a couple on the go and plan to get them out just before Christmas [or maybe a little bit after]

So my overall impressions with QGIS, if you couldn’t tell already, are: very very impressed with a very strong feeling it’s only going to get better.

So if you’re interested in trying something new, give QGIS a go.

Some handy links: