Last active
October 30, 2017 15:06
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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