NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

I'm currently using the following query to retrieve all the streets/roads within distance of a lat, long location:

[out:json]; way["highway"](around:${distance},${lat},${long}); out;;

However instead of getting a single record for each Street/road, I'm getting back multiple records (ways). Is there a way to get one record per real world road/Street?

asked 06 May '18, 02:10

mkhalila's gravatar image

accept rate: 0%

No, there is not; you will have to write code yourself that combines objects, because for every use case, the definition of what should be one object is different:

  • A street may have "side arms" with the same name as the street, therefore it cannot be combined into one linear geometry.
  • A street may consist of several disjunct parts, e.g. if the street is cut in two by a small plaza or a large other street, and therefore also not be representable as one linear geometry.
  • Even where various OSM ways with the same street name are connected and could therefore be combine into one geometry, they will often have different attributes, e.g. one part could be highway=secondary and the other highway=residential, or one part could have a different surface or speed limit. Overpass cannot know what your conditions are for connecting the bits, and if bits were connected, which of the several highway type, or surface, or maxspeed values it should return for the combined object.
permanent link

answered 06 May '18, 09:12

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
accept rate: 23%

Thank you for that answer Frederick, that clarifies whether it's possible or not.

I suspected I'd have to do it myself. Which is what I've been attempting to do last few weeks but I'm struggling to come up with a way of combining ways into a street whilst maintaining the integrity of the data.

I can't just go via the name because two cities may have roads with the same name. I've tried going via ref of the way but that also only covers a small minority of the ways since in certain areas, only a few ways have a ref defined.

I could take a request and break it down into tiny requests spanning a tiny region and then join all the data together. That would maintain integrity of data mostly, however it'll create a ridiculous amount of overpass query requests.

Is there a way of getting the area/city a way belongs to given the ID and/or name of the way? I can use this to group ways with the same name that belong to the same area.

(06 May '18, 18:56) mkhalila


Alternatively, is there a way of getting the lat, long location of a way given its ID and/or name? I could use this location to also group ways with the same name. Or even better, is there a way of modifying the above query to also retrieve the location of that way?

Another alternatively, in the above query I'm getting all ways within a certain distance of a lat, long location. At the moment it returns the ways but doesn't return the exact distance they are from the lat,long location. Is there a way of getting that?

Apologies for the brain dump, I've thought about possible solutions for months but I'm unsure of how to achieve this within the QL.

Any help is always appreciated. Thanks in advance.

(06 May '18, 18:56) mkhalila

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 06 May '18, 02:10

question was seen: 2,291 times

last updated: 06 May '18, 18:56

NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum