Click here to Skip to main content
15,891,184 members
Articles / Desktop Programming / MFC

Mapinfo Tab to ESRI Shapefile Converter

Rate me:
Please Sign up or sign in to vote.
1.56/5 (12 votes)
2 Dec 2010CPOL 99.2K   2.3K   27   8
A batch converting tool that can convert GIS data from "mapinfo tab" to "ESRI shapefile".

Sample Image - MapinfoTab2Shp.jpg

Introduction

Mapinfo tab to ESRI shapefile converter can convert MapInfo vector tables to the ESRI shape format. It is implemented as a command line interface to IMUT.exe.

Using the Code

This is a code sample, and will only work with Universal Translator Imut files.

C++
char szExeFile[1024];
sprintf(szExeFile, "\"%s\\imut.exe\" CFGenerate " 
        "MAPINFO SHAPE \"%s/\" hggtemp1.dat LOG_STANDARDOUT YES", 
        (LPCTSTR)m_strImut,(LPCTSTR)strFilePath);

STARTUPINFO si;
GetStartupInfo( &si );
PROCESS_INFORMATION pi;
si.dwFlags = STARTF_FORCEONFEEDBACK;
si.wShowWindow = SW_HIDE;

if(CreateProcess(NULL,
    szExeFile,
    NULL,
    NULL,
    FALSE,
    CREATE_DEFAULT_ERROR_MODE,
    NULL,
    (LPCTSTR)m_strImut,
    &si,
    &pi))
{
    CloseHandle(pi.hThread);
    WaitForSingleObject(pi.hProcess, INFINITE);
    //GetExitCodeProcess(pi.hProcess, &dwExitCode);
    CloseHandle(pi.hProcess);
    
    FILE *fp;
    sprintf(szExeFile, "%s\\hggtemp2.dat",(LPCTSTR)m_strImut);
    if((fp = fopen(szExeFile, "wt")) != NULL)
    {
        fprintf( fp, "MACRO _EXTENSION TAB\n");
        fprintf( fp, "MACRO SourceDataset %s\n", (LPCTSTR)strFilePath);
        fprintf( fp, "MACRO DestDataset %s\n", strDstPath);
        fprintf( fp, "INCLUDE hggtemp1.dat\n");
        fclose(fp);
        
        sprintf(szExeFile, "\"%s\\imut.exe\" hggtemp2.dat", (LPCTSTR)m_strImut);
        if(CreateProcess(NULL,
            szExeFile,
            NULL,
            NULL,
            FALSE,
            CREATE_DEFAULT_ERROR_MODE,
            NULL,
            (LPCTSTR)m_strImut,
            &si,
            &pi))
        {
            CloseHandle(pi.hThread);
            WaitForSingleObject(pi.hProcess, INFINITE);
            //GetExitCodeProcess(pi.hProcess, &dwExitCode);
            CloseHandle(pi.hProcess);
        }
    }
}

Points of Interest

The tool can convert a lot of tab files (located in a different directory) to shapefile format. Manual operation is a tiring, trouble thing; it may cause an error.

History

  • 18th June, 2006: First release.
  • 2nd December, 2010: Updated source code.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
China China
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralAlmost Pin
psy2319-Apr-11 11:12
psy2319-Apr-11 11:12 
GeneralMy vote of 1 Pin
aydinsahin4-Dec-10 11:22
aydinsahin4-Dec-10 11:22 
GeneralEnglish please Pin
Muammar©5-Jun-07 1:09
Muammar©5-Jun-07 1:09 
GeneralMapinfdo file format Pin
AlexEvans19-Jun-06 13:12
AlexEvans19-Jun-06 13:12 
GeneralRe: Mapinfo file format Pin
gxdata19-Jun-06 18:13
gxdata19-Jun-06 18:13 
In isolation, this article will not mean very much at all to 99% of people who visit Code Project.

Round-about answer:
TAB file format really refers to a series of files. The TAB one absolutely requires some other files (I'll skip over that). It's better called a "MapInfo TAB fileset".
The MapInfo file format is "better" known via other file formats, the .MIF and .MID file pair that MapInfo Professional can export. They are text-format, and there is public info about them.
TAB fileset formats are described in various places, but there are different versions of it/them.

But that's irrelevant to the article, because it depends on having a licensed copy of MapInfo Professional, and also the UTM utility that is licensed by MapInfo Corporation from Safe Software (and installed with MapInfo).


Question?? Pin
Jonathan [Darka]18-Jun-06 23:09
professionalJonathan [Darka]18-Jun-06 23:09 
AnswerRe: ?? Pin
trevor.hart19-Jun-06 0:13
trevor.hart19-Jun-06 0:13 
GeneralRe: ?? Pin
Jonathan [Darka]19-Jun-06 0:17
professionalJonathan [Darka]19-Jun-06 0:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.