Updating the buildings table with coordinates SQL

This commit is contained in:
Ed Chalstrey 2022-04-04 11:42:27 +01:00
parent 66138855a3
commit 0048f0ae73
2 changed files with 8 additions and 3 deletions

View File

@ -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

View File

@ -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;"