Created
May 19, 2012 08:19
-
-
Save laacz/2730058 to your computer and use it in GitHub Desktop.
PostGIS: Find nearest roads (represented by linestring) to a given point
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Road data comes from OpenStreetmap (http://download.geofabrik.de/osm/) | |
**/ | |
select st_distance(st_closestpoint(r.the_geog::geometry, wa.location::geometry), wa.location::geometry) as cp | |
, r.name | |
, r.ref | |
, r.ogc_fid | |
, r.type | |
, st_astext(wa.location) | |
, wa.* | |
from points_of_interest wa, roads r | |
where wa.id = 'some-poi-id' | |
and (r.name is not null or r.ref is not null) | |
order by cp asc | |
limit 10 | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment