[gdal-dev] Different result from GML with .xsd and .gfs

Even Rouault even.rouault at mines-paris.org
Sun Jan 22 06:16:36 EST 2012

Le dimanche 22 janvier 2012 12:03:02, Jukka Rahkonen a écrit :
> Hi,
> I have been doing conversions from Mapinfo files with iso-8859-1 encoding
> into Spatialite by using GML format as an interim format. I have noticed
> that in I let ogr2ogr to create .xsd file the conversion of attribute
> names with non-ascii characterd does not go in a righ way even if I edit
> both the .gml and .xsd fileto have correct encoding in the header line.
> But if I do not have .xsd file at all and ogr2ogr creates .gfs file when
> doing the GML -> Spatialite conversion the result seems to be correct.
> This can be tested with this Mapinfo file
> http://latuviitta.org/documents/m_asalue.zip
> 1. ogr2ogr -f GML testi.gml m_asalue.tab
> 2. edit encoding header of testi.gml and testi.xsd into iso-8859-1
> 3. ogr2ogr -f SQLite -dsco spatialite=yes -a_srs epsg:2392 test_1.sqlite
>    test.gml
> 4. delete testi.xsd file
> 5. ogr2ogr -f SQLite -dsco spatialite=yes -a_srs epssg:2392 test_2.sqlite
>    test.gml
> When I open testi_1.sqlite with Spatialite-gui it shows one attribute name
> in a wrong way but it looks correct in testi_2.sqlite.

Yes, this is due to the XML mini parser directly integrated to GDAL that is 
used to parse the .xsd. It doesn't understand the XML encoding header, so 
assumes the content to be always utf-8.

As suggested by someone in a previous related bost, you'd better use iconv 
instead of editing the files.

1) ogr2ogr -f GML testi.gml m_asalue.tab
2) iconv -f iso-8859-1 -t utf-8 < testi.gml > testi_utf8.gml
3) iconv -f iso-8859-1 -t utf-8 < testi.xsd > testi_utf8.xsd
4) ogr2ogr -f SQLite -dsco spatialite=yes -a_srs epsg:2392 test.sqlite 

> -Jukka Rahkonen-
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev

More information about the gdal-dev mailing list