Skip to content

Instantly share code, notes, and snippets.

@bitner
Created September 28, 2011 17:04
Show Gist options
  • Save bitner/1248501 to your computer and use it in GitHub Desktop.
Save bitner/1248501 to your computer and use it in GitHub Desktop.
KNN GIST query
select
parcel_id,
address,
st_distance(geom,'SRID=3005;POINT(1011102 450541)') as distance
from
parcels
where
geom && (
select
st_extent(geom)
from
parcels
order by geom <#> 'SRID=3005;POINT(1011102 450541)'
limit 10
)
order by st_distance(geom,'SRID=3005;POINT(1011102 450541)') limit 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment