Is there a way to encode shapefiles from LATIN1 to UTF-8?
3 Answers
Assuming that you are on Linux and have access to a recent version of GDAL you can try the following (from this post) :
export SHAPE_ENCODING="ISO-8859-1"
ogr2ogr output.shp input -lco ENCODING=UTF-8
Note: LATIN1 should work too instead of ISO-8859-1.
In Windows, do NOT set the SHAPE_ENCODING, ogr2ogr does not recognize ISO-8859-1, nor LATIN1.
- 113
- 4
- 7,339
- 22
- 33
You can do this with QGIS. First load your shapefiles then save as and coding select dropdown menu utf-8 and then save your file.
-
9Word of caution: for this solution to work qgis must be started in a LATIN1/ISO-8859-1 environment when you open the input shapefile or it won't read it correctly. If you are working in an UTF8 enviroment the conversion might fail silently, corrupting the data, depending on the data in the shapefile. BTW, most OSes now default to UTF8. – unicoletti Oct 19 '11 at 15:48
-
1Note that in some situations it may not work, I had this kind of issues: (http://osgeo-org.1560.n6.nabble.com/UTF-8-no-more-td4647456.html) – JaakL Jul 16 '12 at 05:48
-
I am trying to save single shape file from system to utf-8 but it is not working. http://gis.stackexchange.com/questions/219092/how-to-change-shapefile-data-source-encoding-directly – Muhammad Faizan Khan Nov 25 '16 at 10:09
If my understanding of Shapefiles is correct, the part that is encoding-sensitive is the attribute database contained in the DBF file.
Here is an answer that helped me solve this issue using LibreOffice Calc/Base:
https://gis.stackexchange.com/a/3663/17998
It has the additional benefit that you can open the DBF file using a distinct character set and thus find out what the current encoding actually is.
SHAPE_ENCODINGsomewhere? – JJD Feb 28 '14 at 13:30