Skip to content

Instantly share code, notes, and snippets.

@oskarlin
Last active October 30, 2017 15:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oskarlin/51e3758ce1f1d89440324eb0a564a65f to your computer and use it in GitHub Desktop.
Save oskarlin/51e3758ce1f1d89440324eb0a564a65f to your computer and use it in GitHub Desktop.
Unorthodox method of encoding conversion of shape files between latin6 to UTF8 using ogr2ogr
#!/bin/sh
mkdir utf8
export SHAPE_ENCODING="latin6"
echo "Converting to geojson..."
for i in *.shp
do
f=$(echo $i| cut -d'.' -f 1)
ogr2ogr -f GeoJSON utf8/${f}.geojson ${f}.shp
echo "${f}.shp to ${f}.geojson"
done
export SHAPE_ENCODING="utf-8"
echo "Converting back to shp igen..."
for i in *.geojson
do
f=$(echo $i| cut -d'.' -f 1)
ogr2ogr -f "ESRI Shapefile" -a_srs EPSG:3006 utf8/${f}_utf8.shp utf8/${f}.geojson -lco ENCODING=UTF-8
echo "${f}.geojson to ${f}_utf8.shp"
rm utf8/${f}.geojson
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment