Getting datafiles into (and
out of) MapInfo
4Understanding MapInfo: A Structured Guide
Ian Johnson 1996. Archaeology (P&H), University of Sydney
This chapter is primarily concerned with data which already exist in a database, spreadsheet,CAD package, desktop mapping package or GIS. You can safely skip it if your data is alreadyin MapInfo format or you will be entering data from scratch.
Direct entry of tabular data through a Browser or the Info tool, and drawing of map objectswith the mouse or digitiser, are covered in chapters 6, 7 and 9. Exporting maps as bitmaps orvector images will be covered in chapter 10.
There are several programs available on the GISNet MapInfo FTP site (Appendix I) forconverting data from other programs or file formats to MapInfo. These include tools forArc/Info, MicroStation, GRASS, Idrisi, SAS, DLG and Tiger94.
Data in a conventional database may relate to objects (in the broadest sense) such as plants,animals, buildings or incidents, but will not generally carry graphical or map representations ofthose objects. These data are referred to as tabular data, as contrasted with map data, whichare the outlines or symbols used to represent objects on a map (see chapter 2).
Often these data will consist of point objects, i.e. objects which have no substantial size orshape in relation to the map as a whole - they are merely represented by a point (or symbol) atsome location specified by an X,Y coordinate pair. Typical point data will be samplinglocations, plant observations, species sightings, incidents, archaeological sites, artefacts, orbuildings (although each of these may be treated as polygon data under other circumstances).
Point objects can be simply created from their geographic location using the Table>CreatePoints command (page 64) so they are easily imported as a file containing tabular data alone.Line and area map objects are more problematical, requiring creation of an outline throughdrawing or digitising, or through import from an external source. Import of line and area objectstherefore generally requires data in a tabular + graphical data format, such as AutoCADDrawing Exchange Format or MapInfo Interchange Format (pages 58 - 63), or the joining oftabular data with existing map objects (page 175).
The first part of this chapter deals with files containing tabular data only.
Opening tabular data files
MapInfo's File>Open Table (Ctrl-O) command allows MapInfo to open tabular data files inseveral common formats and turn them into MapInfo tables (the original file is not affected bythis process - MapInfo simply creates a .TAB file to tell it how to access the data in the originalfile). Select the format using the File Format pull-down list on the Open Table dialogue box.
4Getting data files into (and out of) MapInfo
The formats currently supported are:
DBase (.DBF)Delimited ASCII (.TXT)Lotus 1-2-3 spreadsheet (*.WK1/S/3/4)1
Microsoft Excel spreadsheet (*.XLS)
Tables opened in this way will contain tabular data only, since these formats do not allow formap objects. Map objects can be added with the Table>Create Points command (page 64) orby joining the table of tabular data with another table containing map objects (page 175).
The File>Open Table command will also open raster (bitmap) images - pages 11, 219. Once araster file has been opened once it will appear as a MapInfo format table on future Open Tabledialogues.
MapInfo can also access data in the formats listed above, and in a number of other commonformats including SQL server databases, through ODBC (Open Database Committee) driversusing File>Open ODBC Table. A discussion of ODBC drivers is beyond the scope of thisvolume: if you already have data you want to access in this way, consult the ODBC sections ofMapInfo Reference (pages 243 - 256, 317, 423) and MapInfo User's Guide (chapter 19 andAppendix D), or your network administrator.
MapInfo will pick up the field names and types automatically from DBase files. Transferbetween MapInfo and DBase format is two-way - MapInfo can modify both the file structureand the data in DBF files and recognises both structure and data modifications made by otherprograms.2 MapInfo's own internal tabular data file format (.DAT) is simply a modified DBaseDBF file (allowing additional field types).
Many database management systems can work directly with files in DBase DBF format,although functionality is generally restricted compared with the system's native format (e.g.Paradox can create and use DBF files but is restricted to DBase's limited range of field types). Itmay however be possible to program the database system to automatically transfer the datarequired by MapInfo into a DBase file on a regular, even continuously updated, basis (but seefollowing paragraph).
When MapInfo accesses a DBase table, it locks not just the record it is modifying but the entiretable. Simultaneous updating by MapInfo and a database management system is therefore notpossible. If one or more users require simultaneous access to the same tabular database usingboth MapInfo and a database management system, or if the database is frequently updated and
1 MapInfo only supports the older Lotus formats (Lotus 1-2-3 releases 1 - 4) with extensions WK1, WKS, WK3 and WK4and Excel up to the current version at time of release. You may have to save newer format files in a format compatiblewith an older version to allow MapInfo to access the file. MapInfo may also have problems with multiple worksheets -data should be restricted to the first worksheet.
42 Both programs should recognise if the tabular data has been modified by the other program and should rebuild their
index files accordingly. MapInfo seems to do this reliably. This does not always happen the other way round, requiringmanual index rebuilds in the database program when tabular data has been modified in MapInfo. This problem may bespecific to particular DBase or DBase-compatible implementations.
Getting data files into (and out of) MapInfo
you need to be able to display the latest data, you should use the ODBC table function ofMapInfo to access the data directly.
ODBC also gives MapInfo direct access to data in an SQL server application, allowingretrieval, insertion, update and deletion of records from any server database supporting theODBC standard. The server application and MapInfo's ODBC table function will take care ofmanaging record locking and other functions required to handle multiple users and maintainintegrity of the data.
Spreadsheet and ASCII delimited files
Transfers between MapInfo and spreadsheet or ASCII delimited formats are strictly one-way,data source to MapInfo. Neither the structure nor the data in a spreadsheet or ASCII delimitedfile is modifiable from within MapInfo.
If the structure of a spreadsheet or ASCII delimited file is changed by another program,MapInfo may lose track of the data. The data values can, however, be changed by anotherprogram, and the updated data will be used by MapInfo.
For spreadsheet files, MapInfo will pick up an entire worksheet or a defined block of cells.MapInfo will also read the field (column) names from the row preceding the defined block ifthe Use Row Above Selected Range for Column Titles box is checked:
MapInfo will automatically select the range of cells in the full worksheet, as shown by CurrentValue above. Pull down the list under Named Range to choose other worksheets within thespreadsheet file opened (if any). To select data from a specified range, select Other... from thepull-down list under Named Range and type in the cell range in the following dialogue:
MapInfo determines the field type for each column in the spreadsheet by looking at the valuesin the column. If any value is non-numeric, it will set the column to a character field type.
Field widths are determined from the column width set in the spreadsheet. If data in a columnexceed this width, the data will be truncated.
Getting data files into (and out of) MapInfo
h You will be well advised to save your spreadsheet files as a MapInfo native format file, usingFile>Save Copy As, to improve access speed and allow modifications to the file (e.g. additionof columns to hold calculated fields). See notes on pages 55 - 56.
There are some problems with opening .WK4 files with multiple worksheets and complexformatting, which may result in garbage. It is best to keep the data simple as you expect to seeit in the MapInfo table.
ASCII delimited files
If your data is stored in a database or spreadsheet other than those supported directly or throughDBase files or ODBC drivers, the software can almost certainly export ASCII delimited files,which MapInfo can open.
h One advantage of transferring data from a database system to MapInfo via a delimited file isthat the database system can be programmed, through a report, to com