-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathprepare-data.sh
69 lines (59 loc) · 1.94 KB
/
prepare-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
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
set -e
NE_FULL_DOWNLOAD=false
mkdir -p data
# Download planet OSM if it does not exist
# https://planet.openstreetmap.org/
if [ ! -f data/planet-latest.osm.pbf ]; then
echo "Dowloading planet-latest.osm.pbf"
time wget https://planet.openstreetmap.org/pbf/planet-latest.osm.pbf \
--quiet -O data/planet-latest.osm.pbf
fi
# Download Natural Earth GeoPackage
# https://www.naturalearthdata.com/downloads/
if [ ! -f data/natural_earth_vector.gpkg ]; then
if [ "$NE_FULL_DOWNLOAD" = true ]; then
echo "Downloading natural_earth_vector.gpkg"
time wget http://naciscdn.org/naturalearth/packages/natural_earth_vector.gpkg.zip \
--quiet -O data/natural_earth_vector.gpkg.zip
unzip -j natural_earth_vector.gpkg.zip
rm CHANGELOG VERSION README.md
else
python scripts/naturalearth.py -v \
data/natural_earth_vector.gpkg
fi
fi
# Filter by amenity tag with osmium-tool
# https://osmcode.org/osmium-tool/
if [ ! -f data/planet-amenity.osm.pbf ]; then
time osmium tags-filter \
data/planet-latest.osm.pbf amenity \
-o data/planet-amenity.osm.pbf
fi
# Get the most popular tags from taginfo
# taginfo.openstreetmap.org/
if [ ! -f data/taginfo_amenity_counts.csv ]; then
python scripts/taginfo.py -v amenity \
data/taginfo_amenity_counts.csv
fi
# Download and prepare NUTS regions including population
if [ ! -f data/nuts_60m.gpkg ]; then
python scripts/eurostat_nuts.py -v \
--resolution 60m \
data/nuts_60m.gpkg
fi
# Extract centroids from amenities
if [ ! -f data/planet-amenity.csv.gz ]; then
python scripts/extract.py \
data/planet-amenity.osm.pbf \
data/planet-amenity.csv.gz \
--key amenity \
--verbose
fi
# Perform spatial join between amenities and NUTS regions
if [ ! -f data/europe-amenity-counts.csv.gz ]; then
python scripts/spatial_join.py
fi
# Calculate normalized amenity features based on population
if [ ! -f data/europe-amenity-features.csv.gz ]; then
python scripts/features.py
fi