Skip to content

Instantly share code, notes, and snippets.

@ajashton
Created February 8, 2011 16:15
Show Gist options
  • Save ajashton/816670 to your computer and use it in GitHub Desktop.
Save ajashton/816670 to your computer and use it in GitHub Desktop.
#!/bin/bash
MERGEDNAME="school_districts"
OUTDIR="/tmp"
for INFILE in *.shp; do
OUTFILE="${OUTDIR}/${MERGEDNAME}.shp"
if test -e "$OUTFILE"; then
echo "Merging $INFILE..."
ogr2ogr -f "ESRI Shapefile" -update -append \
"$OUTFILE" "$INFILE" -nln "$MERGEDNAME"
else
echo "Creating $OUTFILE from $INFILE..."
ogr2ogr -f "ESRI Shapefile" "$OUTFILE" "$INFILE"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment