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 :)

13 thoughts on “New Tool: MapInfo to QGIS style converter

  1. Thanks. Does your tool require MapInfo? How about turning your script into a QGIS plugin, so users could load styles directly?

    1. If you use the –UseMapInfo switch it does but if you have a txt file in the right format (python mapinfoToQgis.py –help will show the format) you can use python mapinfoToQgis.py in.txt out.qml -c myColumn and it doesn’t use MapInfo. Although you will need MapInfo at some level to get the style string from the MapInfo TAB file as no open source tool seems to read that part of the format.

      Turning it into a plugin is on the to do list, I just want to get a stable stand alone tool before adding the QGIS layer on top.

      1. Have you looked at the opensource c++ library “MiTab” ? It can read and write tab files. AFAIK, it can read the style information of the individual features in the tab file. I don’t know if there exists any python bindings for the library, but the api is a c-based, so it can’t be impossible to write a python wrapper.

    1. QGIS currently does not make use of the feature style hints provided by OGR, so it might be interesting to take a look at that since this would also help some other formats that contain styling information.

      1. Yeah it might be a good project at some stage. OGR seems to ignore anything but simple styling for MapInfo files, eg it doesn’t translate font symbols in MapInfo and output anything that can be used via QGSFeature::GetStyleString(), but that should be a simple thing to add. I might have a look into it at some stage.

    1. Thanks! Yeah I’m still working on it I have just been a bit tied up with work and uni to really take it any further. ETA on line and region support is unknown at this stage but hopefully in the next month or so.

  2. Thanks for the hard work Nathan. Does anyone know if there is a tool to do the opposite? In other words, export QGIS symbology to MapInfo.

Leave a comment