2

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.

asked Jan 27, 2014 at 13:13
3
  • 1
    Did you tried latin1 encoding? SHAPE_ENCODING="LATIN1". LINUX or Windows? Commented Jan 27, 2014 at 13:30
  • It's in Windows. Also by adding aditional parameter "SHAPE_ENCODING=LATIN1"(as the last parameter) it didnt throw any error, but the result files now are empty assides from metadata. Commented Jan 27, 2014 at 15:26
  • 1
    And SHAPE_ENCODING=ISO-8859-4, i.e. the ISO alias of Latin 4? Commented Jan 27, 2014 at 16:03

1 Answer 1

1

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.

answered Jan 27, 2014 at 16:07
1
  • If i use ogr2ogr --config SHAPE_ENCODING ISO-8859-4 -f KML output.kml input.shp then it will give out warning "Warning 1: marĒieris is not a valid UTF-8 string. forcing it to ASCII." Forcing can be disabled by OGR_FORCE_ASCII NO but then special characters are question marks. Also when tried with ISO-8859-1 it didn't change anything, nor it gave any warning, so i assume that is the default used encoding here. Commented Jan 28, 2014 at 9:07

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.