create script to load new geometries
This commit is contained in:
parent
5b2029a4e3
commit
d6ca8852d4
20
etl/load_new_geometries.sh
Normal file
20
etl/load_new_geometries.sh
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Load new geometries from GeoJSON to Postgres
|
||||||
|
# - assume postgres connection details are set in the environment using PGUSER, PGHOST etc.
|
||||||
|
|
||||||
|
: ${1?"Usage: $0 ./path/to/mastermap/dir"}
|
||||||
|
|
||||||
|
mastermap_dir=$1
|
||||||
|
|
||||||
|
# Create 'geometry' record with
|
||||||
|
# id: <polygon-guid>,
|
||||||
|
# source_id: <toid>,
|
||||||
|
# geom: <geom>
|
||||||
|
|
||||||
|
echo "Copy new geometries to db..."
|
||||||
|
find $mastermap_dir -type f -name '*.3857.csv' \
|
||||||
|
-printf "$mastermap_dir/%f\n" | \
|
||||||
|
parallel \
|
||||||
|
cat {} '|' psql -c "\"COPY geometries ( geometry_geom, source_id ) FROM stdin WITH CSV HEADER
|
||||||
|
WHERE source_id NOT IN geometries;\""
|
Loading…
Reference in New Issue
Block a user