-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget_osm_data.sh
executable file
·41 lines (32 loc) · 1.02 KB
/
get_osm_data.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
#!/bin/bash
# Extract highways from OSM data that are within the boundary of the
# city of Karlsruhe. The data is stored in `highways.osm`.
#
# Requires the `osmosis` tool.
#
# Download data if necessary
#
DIR=http://download.geofabrik.de/europe/germany/baden-wuerttemberg
BASE=karlsruhe-regbez-latest.osm.pbf
if [ -f "${BASE}" ]; then
# Download MD5 file to see if file is up-to-date
echo "${BASE} exists, downloading MD5 to check whether it's up to date."
wget -q -N ${DIR}/${BASE}.md5 -O ${BASE}.md5
LATEST_MD5=$(<${BASE}.md5)
FILE_MD5=`md5sum ${BASE}`
if [ "$LATEST_MD5" == "$FILE_MD5" ]; then
echo "File is up to date."
else
echo "File is outdated, downloading latest version."
wget ${DIR}/${BASE} -O ${BASE}
fi
else
echo "${BASE} doesn't exist, downloading it."
wget ${DIR}/${BASE} -O ${BASE}
fi
#
# Extract coordinates for things in Karlsruhe
#
osmosis --read-pbf file=${BASE} \
--bounding-polygon file=karlsruhe.poly \
--write-xml karlsruhe.osm