Wmo & Co
 
waypoints
20141203

Pulling waypoints from an OpenStreetmap .OSM file

Before going on holiday, I like to gather the OpenStreetMap waypoints for the area I'll be staying at. This is the process.

Download an .osm file

Eg. pick one from download.geofabrik.de

Pull out all the nodes of the area of interest

The area is determined by lat,lon coordinates and the distance from this point. Eg. pulling data from the central-america .osm file, in radius of 10k around Willemstad, Curacao:

./pull central-america-latest.osm 12.1166 -68.9333 10  > willemstad10k.csv

Source code for pull.go on github.

Post-process

Subsetting, selecting, etc.. using Python Pandas

Read the .csv file in Pandas (in an ipython session) :

import pandas as pd

df=pd.read_csv('willemstad10k.csv',header=None,names=['lat','lon','name','marker','dist','tags'])

Sort according to distance, and convert tags to lowercase:

df.sort(columns='dist',inplace=True)
df['tags']=df.tags.str.lower()

Subset the restaurants

r = df[df.tags.str.contains("restau")][['lat','lon','name','dist','tags']]

Now give me the chinese restaurants

r[r.tags.str.contains("chin")]

           lat        lon                        name   dist  tags
1917  12.120777 -68.897536  Chinese Restaurant and Bar  3.91  "[ .. {name chinese restaurant and bar}..
1872  12.121817 -68.895336                      Chindy  4.16  "[ .. {cuisine chinese} ..
2189  12.154782 -68.946812     Santa Maria Food Center  4.49  "[ .. {cuisine chinese} ..
1575  12.124456 -68.889972                       Winer  4.79  "[ .. {cuisine chinese} ..

See more detail (plus the source code) at github.com/wmo/pull_osm_nodes

 
Notes by Willem Moors. Generated on nini:/home/willem/sync/20140923_blog at 2018-06-16 11:17