From fa89fe98f6ca9ee3ae27391c7506916ebef4ec3e Mon Sep 17 00:00:00 2001 From: Will Bradley Date: Sun, 7 Feb 2021 02:36:55 -0800 Subject: [PATCH] Update conflate --- README.md | 2 +- conflation.sql | 34 +++++++++++++++++----------------- trial.sh | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 228a7f2..853cad5 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Here are sample screenshots of Sonoma County, Santa Rosa, the City of Sonoma, an - https://gis-sonomacounty.hub.arcgis.com/datasets/2202c1cd6708441f987ca5552f2d9659 - https://gis-sonomacounty.hub.arcgis.com/datasets/0f5982c3582d4de0b811e68d7f0bff8f - http://download.geofabrik.de/north-america/us/california/norcal-latest.osm.pbf -- VTATaz: https://drive.google.com/file/d/0B098fXDVjQOhVHBFS0kwcDNGRlU/view +- VTATaz (included in git, original_data): https://drive.google.com/file/d/0B098fXDVjQOhVHBFS0kwcDNGRlU/view Script: ``` diff --git a/conflation.sql b/conflation.sql index 6a95f99..06d1d92 100644 --- a/conflation.sql +++ b/conflation.sql @@ -4,15 +4,15 @@ -- add fields for OSM tags and data processing ALTER TABLE sonoma_county_building_outlines - ADD COLUMN "addr:housenumber" text, - ADD COLUMN "addr:street" text, - ADD COLUMN "addr:unit" text, - ADD COLUMN "addr:city" text, - ADD COLUMN "addr:state" text, - ADD COLUMN usecode integer, - ADD COLUMN loc_geom geometry(multipolygon,4326), - ADD COLUMN conflated boolean DEFAULT FALSE, - ADD COLUMN main boolean; -- is it the main building on the parcel? + ADD COLUMN IF NOT EXISTS "addr:housenumber" text, + ADD COLUMN IF NOT EXISTS "addr:street" text, + ADD COLUMN IF NOT EXISTS "addr:unit" text, + ADD COLUMN IF NOT EXISTS "addr:city" text, + ADD COLUMN IF NOT EXISTS "addr:state" text, + ADD COLUMN IF NOT EXISTS usecode integer, + ADD COLUMN IF NOT EXISTS loc_geom geometry(multipolygon,4326), + ADD COLUMN IF NOT EXISTS conflated boolean DEFAULT FALSE, + ADD COLUMN IF NOT EXISTS main boolean; -- is it the main building on the parcel? update sonoma_county_building_outlines set "addr:housenumber" = NULL, "addr:street" = NULL, "addr:unit" = NULL, "addr:city" = NULL, "addr:state" = NULL; @@ -22,14 +22,14 @@ update sonoma_county_building_outlines set "addr:housenumber" = NULL, "addr:stre -- added fields for the parcels table ALTER TABLE parcels__public_ - ADD COLUMN "addr:housenumber" text, - ADD COLUMN "addr:street" text, - ADD COLUMN "addr:unit" text, - ADD COLUMN "addr:city" text, - ADD COLUMN "addr:state" text, - ADD COLUMN loc_geom geometry(multipolygon,4326), - ADD COLUMN building_count integer, - ADD COLUMN repeating BOOLEAN DEFAULT FALSE; + ADD COLUMN IF NOT EXISTS "addr:housenumber" text, + ADD COLUMN IF NOT EXISTS "addr:street" text, + ADD COLUMN IF NOT EXISTS "addr:unit" text, + ADD COLUMN IF NOT EXISTS "addr:city" text, + ADD COLUMN IF NOT EXISTS "addr:state" text, + ADD COLUMN IF NOT EXISTS loc_geom geometry(multipolygon,4326), + ADD COLUMN IF NOT EXISTS building_count integer, + ADD COLUMN IF NOT EXISTS repeating BOOLEAN DEFAULT FALSE; update parcels__public_ set "addr:housenumber" = NULL, "addr:street" = NULL, "addr:unit" = NULL, "addr:city" = NULL, "addr:state" = NULL; diff --git a/trial.sh b/trial.sh index 0b2116a..a76369f 100755 --- a/trial.sh +++ b/trial.sh @@ -19,7 +19,7 @@ psql --echo-all --command="create extension if not exists postgis;" "${DBNAME}" psql --echo-all --file="103240.sql" "${DBNAME}" -h $PGHOST -U $PGUSER echo "Importing TAZ" -shp2pgsql -d -D -s 103240 -I "data/VTATaz" | psql -d "${DBNAME}" -h $PGHOST -U $PGUSER >/dev/null +shp2pgsql -d -D -s 103240 -I "original_data/VTATaz/VTATaz" | psql -d "${DBNAME}" -h $PGHOST -U $PGUSER >/dev/null # Conflate addresses to buildings psql -v "ON_ERROR_STOP=true" --echo-queries --file="conflation.sql" "${DBNAME}" -h $PGHOST -U $PGUSER