-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathmerge.sh
More file actions
executable file
·31 lines (28 loc) · 821 Bytes
/
merge.sh
File metadata and controls
executable file
·31 lines (28 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
# Merges a directory of shapefiles into one.
# caveats: shapefiles do not support multiple geometry types,
# so all shapefiles must be of the same geometry.
FILE='nl_merged.shp' # name of file to be merged to
LAYER='nl_merged' # must be same as above but without `.shp` extension
SSRS='EPSG:2227' # source CRS
TSRS='EPSG:2227' # target CRS
for i in $(ls *.shp)
do
if [ -f "$FILE" ]
then
echo "transforming and merging $i..."
ogr2ogr \
-f 'ESRI Shapefile' \
-s_srs $SSRS \
-t_srs $TSRS \
-update -append $FILE $i \
-nln $LAYER
else
echo "creating $FILE..."
ogr2ogr \
-f 'ESRI Shapefile' \
-s_srs $SSRS \
-t_srs $TSRS \
$FILE $i
fi
done