Created
June 16, 2016 13:55
-
-
Save tommorris/1f9f9600b52b3a1608b25ff72df0f6ff to your computer and use it in GitHub Desktop.
osm2pgsql
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
# load pbf into postgres | |
osm2pgsql --create -H localhost --database osm ~/Downloads/great-britain-latest.osm.pbf -j -s |
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
-- find restaurants nearby without cuisine tags | |
select name, osm_id, ST_AsGeoJSON(ST_Transform(way, 4326)) as geom, tags, | |
st_distance(ST_Transform(way, 4326), ST_GeomFromText('POINT(YOUR_LONG YOUR_LAT)', 4326)) as dist, | |
array_length(akeys(tags), 1) as tagc | |
from planet_osm_point | |
where (name is not null) and | |
(amenity = 'restaurant') and | |
(tags -> 'cuisine' is null) and | |
(array_length(akeys(tags), 1) = 2) | |
order by st_distance(ST_Transform(way, 4326), | |
ST_GeomFromText('POINT(YOUR_LONG YOUR_LAT)', 4326) | |
) | |
limit 30; | |
-- find named stuff that's nearby that needs more tags | |
select name, osm_id, ST_AsGeoJSON(ST_Transform(way, 4326)) as geom, tags, | |
st_distance(ST_Transform(way, 4326), ST_GeomFromText('POINT(YOUR_LONG YOUR_LAT)', 4326)) as dist, | |
array_length(akeys(tags), 1) as tagc | |
from planet_osm_point | |
where (name is not null) and | |
(array_length(akeys(tags), 1) = 1) | |
order by st_distance(ST_Transform(way, 4326), | |
ST_GeomFromText('POINT(YOUR_LONG YOUR_LAT)', 4326) | |
) | |
limit 30; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment