Click here to Skip to main content
Licence CPOL
First Posted 18 Jun 2006
Views 56,702
Downloads 1,159
Bookmarked 25 times

Mapinfo Tab to ESRI Shapefile Converter

By sun_xf | 2 Dec 2010
A batch converting tool that can convert GIS data from "mapinfo tab" to "ESRI shapefile".
7 votes, 70.0%
1

2
1 vote, 10.0%
3
1 vote, 10.0%
4
1 vote, 10.0%
5
1.96/5 - 10 votes
μ 1.96, σa 2.67 [?]

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.

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)

About the Author

sun_xf

Web Developer

China China

Member


Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralAlmost Pinmemberpsy2312:12 19 Apr '11  
GeneralMy vote of 1 Pinmemberaydinsahin12:22 4 Dec '10  
GeneralEnglish please PinmemberMuammar©2:09 5 Jun '07  
GeneralMapinfdo file format PinmemberAlexEvans14:12 19 Jun '06  
GeneralRe: Mapinfo file format Pinmembergxdata19:13 19 Jun '06  
Question?? PinmemberDarka0:09 19 Jun '06  
AnswerRe: ?? Pinmembertrevor.hart1:13 19 Jun '06  
GeneralRe: ?? PinmemberDarka1:17 19 Jun '06  

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

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

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120209.1 | Last Updated 2 Dec 2010
Article Copyright 2006 by sun_xf
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid