-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathimposm_shapefiles.sh
executable file
·47 lines (39 loc) · 1.5 KB
/
imposm_shapefiles.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
#!/bin/bash
slug=$1
prefix=${slug//-/_}
mkdir -p /mnt/shp/${slug}-imposm
/home/ubuntu/imposm3-0.4.0dev-20170519-3f00374-linux-x86-64/imposm3 import \
-mapping /home/ubuntu/metro-extracts-master/mapping.json \
-read /mnt/output/${slug}.osm.pbf \
-cachedir /mnt/shp/${slug}-imposm \
-srid 4326 \
-write \
-connection postgis://osm:osm@localhost/osm?prefix=${prefix}_ \
-deployproduction
declare -a arr=('admin' 'aeroways' 'amenities' 'buildings' 'landusages' 'landusages_gen0' 'landusages_gen1' 'places' 'roads' 'roads_gen0' 'roads_gen1' 'transport_areas' 'transport_points' 'waterareas' 'waterareas_gen0' 'waterareas_gen1' 'waterways')
for i in ${arr[@]}; do
pgsql2shp \
-rk \
-f /mnt/shp/${slug}-imposm/${slug}_osm_${i}.shp \
-h localhost -P osm -u osm osm \
${prefix}_${i}
ogr2ogr \
-lco ENCODING="UTF-8" \
-f GeoJSON \
-s_srs epsg:4326 \
-t_srs crs:84 \
/mnt/shp/${slug}-imposm/${slug}_${i}.geojson \
/mnt/shp/${slug}-imposm/${slug}_osm_${i}.shp
done
zip -j /mnt/output/${slug}.imposm-shapefiles.zip \
/mnt/shp/${slug}-imposm/${slug}_osm_*.shp \
/mnt/shp/${slug}-imposm/${slug}_osm_*.prj \
/mnt/shp/${slug}-imposm/${slug}_osm_*.dbf \
/mnt/shp/${slug}-imposm/${slug}_osm_*.shx \
/mnt/shp/${slug}-imposm/${slug}_osm_*.cpg
zip -j /mnt/output/${slug}.imposm-geojson.zip \
/mnt/shp/${slug}-imposm/${slug}_*.geojson
rm -r /mnt/shp/${slug}-imposm
for i in ${arr[@]}; do
echo "DROP TABLE ${prefix}_${i} CASCADE" | psql postgresql://osm:osm@localhost/osm
done