This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

How can I check easily if a point is in a street or not.

0

I wish to create some statistic about a distance from different places in a city to the nearest bus station. For this, naturally, I need to check if a certain point is related to a street or not. I intend to do this via a python script, but I don't really know how to approach this. I know python fairly way, and I was hoping to use a python API rather than learning an entire API from scratch for a hobby project.

Any pointers?

asked 16 Nov '14, 16:06

Yotam's gravatar image

Yotam
16223
accept rate: 0%

edited 16 Nov '14, 17:20

aseerel4c26's gravatar image

aseerel4c26 ♦
32.6k18248554


2 Answers:

2

You will likely not get around understanding the OSM data model regardless of which API you use. Given that the model is actually very simple that should not be a problem. The

See

https://wiki.openstreetmap.org/wiki/Elements

https://wiki.openstreetmap.org/wiki/API_v0.6

specifically for your problem see the "Ways for node" call.

A possible python API is https://wiki.openstreetmap.org/wiki/Osmapi

That was the good news.

The bad news is that you are problably setting about this completely wrong.

If this is any more than a very very low volume cursory check you want to do, you should not try to do this via the editing API in the first place. Particularly if this is something you want to do on a regular base you will want to import osm data in to a suitable database schema and perform queries on that database.

Potentially (your question is not quite clear about what kind of distance you are trying to determine, straight line or an actual route on the road/way network) you should be doing this with a routing service/api see for example the accessibility analysis on http://openrouteservice.org/ .

If you give some more information on what you are actually trying to acheive, we can probably give some more pointers.

answered 16 Nov '14, 22:01

SimonPoole's gravatar image

SimonPoole ♦
44.7k13326701
accept rate: 18%

edited 16 Nov '14, 22:05

Hi. Thanks for the replay. My initial though was to create a heat map of my city that show how far is a certain address from the nearest bus stop. I now think that maybe graph that shows the number of houses as a function of distance from the nearest bus stop would be good too. If I could harvest data about bus frequency at each stop, I would factor that in too. But that is not a priority for me.

Note that I have a (hebrew) list of streets in my city, but not house numbers.

(17 Nov '14, 09:13) Yotam

1

According to the OSM wiki about Overpass_API there is a python wrapper for queries:

This leads you to https://github.com/mvexel/overpass-api-python-wrapper

answered 17 Nov '14, 05:48

stephan75's gravatar image

stephan75
12.6k556210
accept rate: 6%

Source code available on GitHub .