Skip to content

Instantly share code, notes, and snippets.

@aaronpdennis
Last active February 24, 2017 03:08
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 aaronpdennis/5f24f49de36a5e0bd8e8ce43dbb936e2 to your computer and use it in GitHub Desktop.
Save aaronpdennis/5f24f49de36a5e0bd8e8ce43dbb936e2 to your computer and use it in GitHub Desktop.
script for converting NAD83 shapefiles in subdirectories to WGS84 GeoJSON
function shp2geojson() {
ogr2ogr -f GeoJSON -s_srs EPSG:4269 -t_srs EPSG:4326 "../../$1.geojson" "$1.shp"
}
for i in ./*/*.zip; do
directory=${i%*.zip}
mkdir "$directory"
cd "$directory"
filename=${directory##*/}
unzip "../${filename}.zip"
for j in *; do
filetype=${j#*.}
mv "$j" "${filename}.${filetype}"
done
pwd
ls
echo "converting shapefile to geojson"
shp2geojson "${filename}"
cd ../..
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment