Is there a way to get the total distance and distance of the different types of ways that make up a relation such as this one?

For example I'd like to know how many kilometers of divided motorway, non-divided primary, etc. make up this route. Do I need to hire a programmer or is there an Overpass query that can generate this kind of data?

asked 30 Mar, 19:50

mdchachi's gravatar image

accept rate: 0%

Some of this information is available with no programming from the Relation Analyzer tool:

By downloading the Way Distribution you can see that this example is almost entirely highway=trunk.

Note that the main highway tag in OSM does not necessarily map directly to concepts such as "divided highway", this tends to be quite country-specific.

permanent link

answered 30 Mar, 21:10

alan_gr's gravatar image

accept rate: 14%

I would like to suggest

for (t["highway"])
  make stat highway=_.val,oneway=set(t["oneway"]),length=sum(length())/2;
for (t["highway"])
  make stat highway=_.val,oneway=set(t["oneway"]),length=sum(length());

Lines 4 and 10 express that you want to sum by the value of the highway tag and could be replaced by another expression. Lines 3 and 10 ensure that oneways and none-oneways are processes separately. Line 6 has a division by 2 to count oneways only with half of their length.

permanent link

answered 30 Mar, 21:27

Roland%20Olbricht's gravatar image

Roland Olbricht
accept rate: 35%

Your answer
toggle preview

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: 30 Mar, 19:50

question was seen: 67 times

last updated: 30 Mar, 21:27

powered by OSQA