Created
December 17, 2015 06:06
-
-
Save andrewharvey/09f1b77f64c6f529e266 to your computer and use it in GitHub Desktop.
Merge many Shape files together using ogr2ogr
This file contains 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 | |
dest_dir="output" | |
dest_layer="shape_file" | |
mkdir -p "${dest_dir}" | |
i=0 | |
for src_file in source/*.shp ; do | |
echo "Reading ${src_file}" | |
if [ $i -eq 0 ] ; then | |
ogr2ogr "${dest_dir}/${dest_layer}.shp" "${src_file}" | |
else | |
ogr2ogr -update -append "${dest_dir}/${dest_layer}.shp" "${src_file}" -nln "${dest_layer}" | |
fi | |
i=$((i+1)) | |
done | |
echo "" | |
echo "Output: ${dest_dir}/${dest_layer}.shp" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment