diff options
author | typebrook <typebrook@gmail.com> | 2019-11-15 22:55:32 +0800 |
---|---|---|
committer | typebrook <typebrook@gmail.com> | 2019-11-15 22:55:32 +0800 |
commit | d895076b6d1959cf8ad4396279dda800d4b606d7 (patch) | |
tree | 1b9b4d7bb48345f5669590e91e55aa3e1a051aac | |
parent | b4509cc6ae75dfb7bca5e7865e565a35a4eb604e (diff) |
update
-rw-r--r-- | utils/osm.village.nat_ref.makefile | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/utils/osm.village.nat_ref.makefile b/utils/osm.village.nat_ref.makefile new file mode 100644 index 0000000..5f59c02 --- /dev/null +++ b/utils/osm.village.nat_ref.makefile | |||
@@ -0,0 +1,44 @@ | |||
1 | data/taiwan-latest.osm.pbf: | ||
2 | mkdir -p data | ||
3 | curl -o $@ http://download.geofabrik.de/asia/taiwan-latest.osm.pbf | ||
4 | |||
5 | data/village.zip: | ||
6 | mkdir -p data | ||
7 | curl -o $@ -L http://data.moi.gov.tw/MoiOD/System/DownloadFile.aspx\?DATA\=B8AF344F-B5C6-4642-AF46-1832054399CE | ||
8 | |||
9 | data/VILLAGE_MOI_1081007.shp: data/village.zip | ||
10 | @if [ ! -e $@ ]; then unzip $< -d data && rm data/*xml data/*xlsx; fi | ||
11 | |||
12 | village.csv: data/taiwan-latest.osm.pbf | ||
13 | ogr2ogr $@ $< \ | ||
14 | -lco GEOMETRY=AS_XY \ | ||
15 | -dialect sqlite \ | ||
16 | -sql "SELECT osm_id, name, other_tags, ST_PointOnSurface(geometry) \ | ||
17 | FROM multipolygons \ | ||
18 | WHERE admin_level = '9'" | ||
19 | |||
20 | village.no_nat_ref.csv: village.csv | ||
21 | grep -v nat_ref $< > $@ | ||
22 | |||
23 | matched.csv: data/VILLAGE_MOI_1081007.shp village.no_nat_ref.csv | ||
24 | ogr2ogr $@ $(word 2,$^) \ | ||
25 | -oo X_POSSIBLE_NAMES=X -oo Y_POSSIBLE_NAMES=Y \ | ||
26 | -dialect sqlite \ | ||
27 | -sql "SELECT osm.osm_id, gov.* \ | ||
28 | FROM 'village.no_nat_ref' osm, '$<'.VILLAGE_MOI_1081007 gov \ | ||
29 | WHERE osm.name = gov.VILLNAME AND Intersects(gov.geometry, osm.geometry)" | ||
30 | |||
31 | confilct.list: matched.csv | ||
32 | cat $< | cut -d',' -f2 | sort | uniq -d | xargs -I {} grep {} $< | ||
33 | |||
34 | origin.osm: matched.csv data/taiwan-latest.osm.pbf | ||
35 | cat $< |\ | ||
36 | sed 1d |\ | ||
37 | cut -d'"' -f2 |\ | ||
38 | sed -nr 's/.*/r\0/p' |\ | ||
39 | osmium getid $(word 2,$^) --id-file - --output-format=osm > $@ | ||
40 | |||
41 | change.list: matched.csv | ||
42 | cat $< |\ | ||
43 | sed 1d |\ | ||
44 | awk -F',' '{print "relation", $$1, "nat_ref", $$2}' > $@ | ||