Skip to content

Instantly share code, notes, and snippets.

@darrell
Last active August 29, 2015 14:24
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 darrell/7fe29b058cf87fd6f079 to your computer and use it in GitHub Desktop.
Save darrell/7fe29b058cf87fd6f079 to your computer and use it in GitHub Desktop.
adjacent parcels with shared ownership
-- if you want to add a buffer, only do so around
-- one geometry, so you can still take advantage
-- of indexes
SELECT DISTINCT a.* from
taxlots a
JOIN taxlots b
ON (a.owner1 in (b.owner1, b.owner2, b.owner3)
OR a.owner2 in (b.owner1, b.owner2, b.owner3)
OR a.owner3 in (b.owner1, b.owner2, b.owner3)
)
WHERE a.tlid<>b.tlid -- don't join to ourselves (which will always be true, and we'd just return the whole table)
AND st_intersects(a.the_geom,b.the_geom);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment