-
Notifications
You must be signed in to change notification settings - Fork 10
/
footprint_append_shp.sh
executable file
·69 lines (69 loc) · 2.19 KB
/
footprint_append_shp.sh
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
#
# ***************************************************************************
# Name : Footprint append shapefile
# Description : Append feature of GeoJSON file to shapefile (if not exist create)
#
# Arguments:
# $1: Shapefile
# $2: GeoJSON
#
# Dependencies : gdal 1.10.1(ogr2ogr)
#
# ***************************************************************************
# begin : 2015-03-02 (yyyy-mm-dd)
# copyright : (C) 2015 by Luiz Motta
# email : motta dot luiz at gmail.com
# ***************************************************************************
#
# Revisions
#
# 0000-00-00:
# - None
#
# ***************************************************************************
#
# Example:
# footprint_append.sh LC8_229-066_20140724_LGN00_r6g5b4.footprint_geojson LC8_footprint.shp
#
# ***************************************************************************
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU General Public License as published by *
# * the Free Software Foundation; either version 2 of the License, or *
# * (at your option) any later version. *
# * *
# ***************************************************************************
#
msg_error(){
local name_script=$(basename $0)
echo "Usage: $name_script <footprint_geojson> <shapefile>" >&2
echo "<footprint_geojson> is the GeoJSON with footprint" >&2
echo "<shapefile> is the Shapefile with all footprint (NEED have extension 'shp')" >&2
}
#
totalargs=2
#
if [ $# -ne $totalargs ] ; then
msg_error
exit 1
fi
#
footprint_geojson=$1
shapefile=$2
#
if [ ! -f "$footprint_geojson" ] ; then
echo "The file '$footprint_geojson' not exist" >&2
msg_error
exit 1
fi
#
if [[ ! $shapefile == *.shp ]] ; then
echo "The file '$shapefile' not have extension '.shp'" >&2
msg_error
exit 1
fi
#
ogr2ogr -update -append -t_srs EPSG:4674 $shapefile $footprint_geojson
printf "Add '$footprint_geojson' in '$shapefile'\n"
exit 0