Search code examples
leafletmapboxopenstreetmapbounding-boxoverpass-api

How to compute bounding boxes of specific roads from Overpass api


I have a high volume dataset with keys like this:

lat:6.897585,
long:52.785805,
speed:12,
bearing:144

Basically it is a dataset of records of various trips on cars. The data was stored every few seconds during each trip. The main goal of this project is to be able to visualize only u-turns (turn arounds) on a map. But for now, I am trying to at least show the data on specifc roads. For that, I am using Overpass APIenter image description here

With the help of Overpass Turbo, I can get a dataset with all the roads I need.

However, in the dataset, the road's geometry is represented with LineString type.

My question is, How can I get a bounding box(es) of the roads from Overpass API, so later on, I can display events that happened only on the given roads? Or maybe you have a better solution on how to achieve this?


Solution

  • A bounding box wouldn't be very helpful here, as using it to filter your points would show everything that falls within the box (which could include other nearby roads)

    It sounds like getting a buffer around a linestring might get you closer, but could still include points that are within the buffer but not on the road you are inspecting.

    The smarter way to do this would be to assign each event to a road segment using some logic based on their attributes/properties, so you don't have to depend on a spatial filter.