Last active
September 13, 2024 07:13
-
-
Save naogify/a2aa57f8f322a063a4af1f9cce300c5f to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
set -ex | |
find . -name "*.shp" | while read -r shpfile; do | |
base=$(dirname "$shpfile")/$(basename "$shpfile" .shp) | |
# .prj ファイルが Shift_JIS だと ogr2ogr でエラーが出るので UTF-8 に変換 | |
if [ -f "${base}.prj" ]; then | |
encoding=$(nkf --guess "${base}.prj") | |
if [ "$encoding" = "Shift_JIS" ]; then | |
nkf --overwrite -w "${base}.prj" | |
fi | |
fi | |
# TODO cpg ファイルがあれば使うように修正 | |
ogr2ogr -f GeoJSON -oo ENCODING=CP932 -t_srs crs:84 "${base}.geojson" "$shpfile" | |
echo "Convert Shape to ${base}.geojson" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment