From 0048f0ae734c80a20e222bfc5cf381898c156fcd Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Mon, 4 Apr 2022 11:42:27 +0100 Subject: [PATCH] Updating the buildings table with coordinates SQL --- etl/README.md | 2 +- etl/load_coordinates.sh | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/etl/README.md b/etl/README.md index 81acc905..7a0b0da9 100644 --- a/etl/README.md +++ b/etl/README.md @@ -175,7 +175,7 @@ Converting the OS Open TOID data OSGB36 Eastings and Northings to WGS84 longitud python convert_opentoid_bng_latlon.py /path/to/opentoids_dir ``` -Assign latitude and longitude to buildings with the downloaded OS Open TOID data. +Assign latitude and longitude to buildings with the converted OS Open TOID data. ```bash ./load_coordinates.sh /path/to/opentoids_dir diff --git a/etl/load_coordinates.sh b/etl/load_coordinates.sh index ae030d4d..690f5bad 100644 --- a/etl/load_coordinates.sh +++ b/etl/load_coordinates.sh @@ -25,8 +25,13 @@ find $opentoid_dir -type f -name '*_converted.csv' \ parallel \ cat {} '|' psql -c "\"COPY open_toid ( toid, version_number, version_date, source_product, easting, northing, longitude, latitute ) FROM stdin WITH CSV HEADER;\"" -# Update the buildings table with coordinates -# psql -c "" +echo "Updating the buildings table with coordinates..." +psql -c "UPDATE buildings + SET location_latitude = open_toid.latitute, + location_longitude = open_toid.longitude + FROM open_toid + WHERE open_toid.toid = b.ref_toid +;" # Delete the temporary table # psql -c "DROP TABLE open_toid;" \ No newline at end of file