Created
September 1, 2017 05:14
-
-
Save johnniehard/dfdc0f95941c58356d48893126c61bb7 to your computer and use it in GitHub Desktop.
Converts all shapefiles in input directory to EPSG:4326 GeoJSON files inside of target directory
This file contains hidden or 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/bash | |
# Johnnie Hård | |
# https://synvinkel.org | |
geojson=".geojson" | |
# These are set by calling the script with arguments e.g: | |
# ./shpfolder2geojson.sh MyShapefileDirectory MyGeojsonDirectory | |
inputdirectory=$1 | |
outputdirectory=$2 | |
mkdir -p | |
for shapefile in ./$inputdirectory/*.shp; do | |
file=$(basename $shapefile) | |
name=${file%.*} | |
targetpath="./${outputdirectory}/" | |
echo "converting $file into $name$geojson" | |
ogr2ogr -f GeoJSON $targetpath$name$geojson -t_srs EPSG:4326 $shapefile | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment