2018-09-21 06:10:39 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2018-09-25 14:20:41 -04:00
|
|
|
#
|
|
|
|
# Extract MasterMap
|
|
|
|
#
|
|
|
|
|
2018-10-04 14:01:17 -04:00
|
|
|
: ${1?"Usage: $0 ./path/to/mastermap/dir"}
|
2018-09-25 14:20:41 -04:00
|
|
|
|
|
|
|
data_dir=$1
|
|
|
|
|
2018-09-21 06:10:39 -04:00
|
|
|
#
|
|
|
|
# Extract buildings from *.gz to CSV
|
2018-05-30 15:18:37 -04:00
|
|
|
#
|
|
|
|
# Features where::
|
|
|
|
# descriptiveGroup = '(1:Building)'
|
|
|
|
#
|
|
|
|
# Use `fid` as source ID, aka TOID.
|
2018-09-21 06:10:39 -04:00
|
|
|
#
|
2018-05-30 15:18:37 -04:00
|
|
|
|
2018-09-25 14:20:41 -04:00
|
|
|
find $data_dir -type f -name '*.gz' -printf "%f\n" | \
|
|
|
|
parallel \
|
|
|
|
gunzip $data_dir/{} -k -S gml
|
2018-05-30 15:18:37 -04:00
|
|
|
|
2018-10-02 16:12:46 -04:00
|
|
|
rename 's/$/.gml/' $data_dir/*[^gzvt]
|
2018-05-30 15:18:37 -04:00
|
|
|
|
2022-03-28 09:02:47 -04:00
|
|
|
# Note: previously the rename cmd above resulted in some temp files being renamed to .gml
|
|
|
|
# so I have specified the start of the filename (appears to be consistent for all OS MasterMap downloads)
|
|
|
|
# we may need to update this below for other downloads
|
2022-03-24 07:41:56 -04:00
|
|
|
find $data_dir -type f -name '*5690395*.gml' -printf "%f\n" | \
|
2018-05-30 15:18:37 -04:00
|
|
|
parallel \
|
|
|
|
ogr2ogr \
|
2018-09-21 06:10:39 -04:00
|
|
|
-select fid,descriptiveGroup \
|
|
|
|
-f CSV $data_dir/{}.csv \
|
|
|
|
$data_dir/{} \
|
|
|
|
TopographicArea \
|
|
|
|
-lco GEOMETRY=AS_WKT
|
|
|
|
|
2018-09-25 14:20:41 -04:00
|
|
|
rm $data_dir/*.gfs
|
2018-10-03 15:10:16 -04:00
|
|
|
rm $data_dir/*.gml
|