Skip to content

Instantly share code, notes, and snippets.

@stelf
Created December 4, 2021 00:03
Show Gist options
  • Save stelf/372c42b33ef5de3d9cf5925d0da84398 to your computer and use it in GitHub Desktop.
Save stelf/372c42b33ef5de3d9cf5925d0da84398 to your computer and use it in GitHub Desktop.
check spatial intersection consistency by making sure no duplicate rows are returned
-- listing only records that appear more than twice
-- in result which finds points within areas
--
-- the partitioning allows us to figure the results
-- alongside corresponding dulplicate areas
--
-- the n.type may be skipped, is included as aexample
select * from (
select
p.pid, n.id, n.type,
count(p.pid) over (partition by p.pid) as pcnt
from
parcels p
inner join
neighborhoods n
on st_within(p.geometry, n.geometry))
where pcnt > 1
order by pcnt desc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment