Distance point to nearest road

I’m looking for a way in order to retrieve some information given a point in OpenStreetMap. The information I need are:

Distance to the nearest Road
Distance to the nearest Major road
Distance to the nearest Highway
Total road length in a buffer with size x [x=50, 100, 200, 300, 500 1000m]

Is there, given a point (latitude - longitude), a way to compute these information by means of the openstreetmap API?



I don’t believe there is any way of getting the answers on a plate. i think you will need to do the geometry and network operations yourself.

Also, how do you define distance? What constitutes a Major Road? What constitutes a Highway?

I don’ t really understand the “in a buffer with size x” bit.

I’d guess you will be happy with plane geometry approximations, and using the centre line of the road, in which case the geometry should be easy. However, it might not be terribly useful if there are obstructions in the way.

I assume you already found the Wikipage https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line

Depending on your programming environment there might be already functions to do the calculation but I didn’t find any hint aboute that searching Google.

Simply load data into PostGIS database with osm2pgsql functions and use PostGIS functions (for which there are many examples of your use cases - just search with Google.)

Just keep an eye for the issues with distances in different geographical projections. PostGIS has geography type, which can help.

I’m currently working with Land Use model in order to define a pollution model given many different data.
The distance is intended in line of view and the buffer is simply the radius given a point of interest.