Skip to content

Instantly share code, notes, and snippets.

@pnorman
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pnorman/9166688 to your computer and use it in GitHub Desktop.
Save pnorman/9166688 to your computer and use it in GitHub Desktop.
address nodes near buildings of the same address but not inside
node,way addr:unit text polygon
node,way addr:housenumber text polygon
node,way addr:street text polygon
node,way addr:city text polygon
node,way building text polygon
node,way z_order int4 linear # This is calculated during import
way way_area real # This is calculated during import
SELECT
poly.osm_id, node.osm_id,
poly."addr:street",
poly."addr:housenumber"
FROM planet_osm_polygon poly
JOIN planet_osm_point node ON (ST_DWithin(poly.way, node.way, 1000))
WHERE poly.building IS NOT NULL
AND poly."addr:housenumber" = node."addr:housenumber"
AND poly."addr:street" = node."addr:street"
AND NOT ST_Intersects(poly.way, node.way);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment