Skip to content

Using MapInfo to QGIS style generator.

NathanW2 edited this page Aug 9, 2011 · 6 revisions

Here is a quick run though on how to use the MapInfo to QGIS style generator.

Preparing the file from MapInfo

Open MapInfo and open the table that you wish to generate the QGIS style for.

Run the following commands in the MapBasic windows, replacing anything in {} with your info

Select {Your value column}, Str$(ObjectInfo(obj,2)) from {Your Table}
Where Str$(ObjectInfo(obj,1)) = "5" Group By {Your value column} Into outputTable

Export "outputTable" Into "{Your output file}.txt" Type "ASCII" Delimiter "|" CharSet "WindowsLatin1"

Follow the instructions below or usage guide to generate QML file.

Generating a QML file.

1: Download the latest version from https://github.com/NathanW2/MapInfo-to-QGIS-style-generator/downloads

2: Extract downloaded zip file anywhere you like.

3: Open OSGeo4W Shell from Start->OSGeo4W->OsGeo4W->OSGeo4W Shell.

4: Change into extracted directory

5: Run python mapinfoToQgis.py {your input file}.txt out.qml -c {your column}

Example

`C:\Temp\NathanW2-MapInfo-to-QGIS-style-generator-f070e6c>python mapinfoToQgis.py
 testInput.txt output.qml -c FittingType`

testInput.txt is included with the download as a example of the file format mapinfoToQgis.py uses.

6: Open layer in QGIS and open layer properties.

7: Select Load Style [1] and select output.qml

Result of loaded QML

8: Symbols should match what was used in MapInfo (minus custom MapInfo 3.0 symbols)

QGIS vs MapInfo styles

A few symbols are missing due to them being custom MapInfo 3.0 Symbols.

Using MapInfo to generating the QML file.

The first step of preparing the txt file can be skipped by using the --UseMapInfo switch with mapinfoToQgis.py

Example

python mapinfoToQgis.py my.TAB out.qml -c FittingType --UseMapInfo

Will load MapInfo and generate the needed txt file and pass that to the QML generator, saving you from having to run queries to get the data into the correct format in MapInfo.