[gdal-dev] Re: MapInfo TAB with WindowsLatin1 into Spatialite

Jukka Rahkonen jukka.rahkonen at mmmtike.fi
Fri Jan 20 04:09:07 EST 2012


Dan Putler <dan.putler <at> sauder.ubc.ca> writes:

> 
> Hi Jukka,
> 
> I think you need to get it to a text form, which GML does. However, 
> rather than hand edit the file, I would run it through recode to convert 
> the character encoding. It would be faster, and not be as error prone as 
> doing by hand. The link to the recode product is: 
> http://recode.progiciels-bpi.ca/index.html
> 

Hi,

I do not need to convert the contents of the GML file that is created with
ogr2ogr. The only trouble is that ogr2ogr writes always into the first 
line ofGML file as

<?xml version="1.0" encoding="utf-8" ?>

This is more or or less clearly documented in the GML driver page "the driver
expects UTF-8 content to be passed in" and so is expects also that UTF-8 is
passed out.

However, the encoding is actually the same than the one used in the original
Mapinfo file, in this case iso-8859-1. But because I know it I can just
correct the first line to be

<?xml version="1.0" encoding="iso-8859-1" ?>

The GML driver itself does support a few different encodings and iso-8859-1
is one of those as documented in http://gdal.org/ogr/drv_gml.html. Therefore
once the encoding parameter in the GML file is corrected GDAL will have 
no trouble in converting GML into Spatialite and from iso-8859-1 into utf-8.

Making conversion through interim GML file is not so hard thing to do but 
it is one more trick to remember and therefore not most convenient. I 
believe that if I will have only one or two files to convert next time I 
will use Quantum GIS. It gives a possibility to select the encoding when 
opening MapInfo files.

I believe it should not be impossible for MapInfo driver to recognise 
encoding automatically because it is written in plain text in the Mapinfo
.TAB file but perhaps ogr generally does not know what to do for the 
encoding even it was known.

-Jukka Rahkonen-



More information about the gdal-dev mailing list