Skip to content

Instantly share code, notes, and snippets.

@psaia
Created May 8, 2012 18:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save psaia/2638080 to your computer and use it in GitHub Desktop.
Save psaia/2638080 to your computer and use it in GitHub Desktop.
Bash Shell Script for merging geographic files
#! /bin/sh
# Path to input files to merge.
FILES=${1-`pwd`}/files-to-merge
# Build directory name.
BUILD_DIR=build
# The outputted shapefile name.
OUTPUT_FILENAME=merged
# Projection type. "ogr2ogr"
PROJECTION=EPSG:900913
###################################################
INDEX=0
for f in $(find $FILES -iname "*.kmz" -or -iname "*.kml" -or -iname "*.shp")
do
echo " ==> $f"
if ((INDEX == 0)); then
ogr2ogr -overwrite -t_srs $PROJECTION ./$BUILD_DIR/$OUTPUT_FILENAME.shp $f
else
ogr2ogr -update -append -t_srs $PROJECTION ./$BUILD_DIR/$OUTPUT_FILENAME.shp $f
fi
let INDEX++
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment