[GIS] Python ogr2ogr language character encoding

encodingexportogr2ogrpython

In python script i'm exporting .shp files to .csv/.gpx/.kml

import ogr, ogr2ogr
...
ogr2ogr.main(["","-f", "CSV", csvfile, shpfile, "-lco", "GEOMETRY=AS_WKT", "-lco", "SEPARATOR=SEMICOLON"])
ogr2ogr.main(["","-f", "GPX", "-dsco", "GPX_USE_EXTENSIONS=YES", gpxfile, shpfile])
ogr2ogr.main(["","-f", "KML", kmlfile, shpfile])

The files are exported, but the language(Latvian) specific string field characters are incorrect. Shape files have string field "LABEL" with a value i.e. "marķieris".

In case of .kml file it is turned into "markieris", and in case of .csv and .gpx it is turned into "maríieris". All exported files have utf-8 (without BOM) encoding.

So far i had no luck finding if i have to pass some kind of additional parameter, or do something else to fix this language issue. Scrip is executed in Windows.

Best Answer

You should try with the following configuration option:

--config SHAPE_ENCODING="ISO-8859-4"

because ISO-8859-4 is the ISO alias of Latin 4.

Latin 4 introduces letters for Estonian, Latvian, and Lithuanian.