Skip to content

Instantly share code, notes, and snippets.

@mhkeller
Last active August 29, 2015 13:56
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 mhkeller/9096933 to your computer and use it in GitHub Desktop.
Save mhkeller/9096933 to your computer and use it in GitHub Desktop.
Merge a directory of shapefiles into one shapefile
#!/bin/bash
mkdir merged;
for f in *.shp;
do
if [ -f merged/merged.shp ]
printf $f
then
ogr2ogr -f "ESRI Shapefile" -update -append merged/merged.shp "$f" -nln Merged
else
ogr2ogr -f "ESRI Shapefile" merged/merged.shp "$f"
fi;
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment