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

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 '21, 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, 21:10

alan_gr's gravatar image

accept rate: 15%

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, 21:27

Roland%20Olbricht's gravatar image

Roland Olbricht
accept rate: 36%

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 '21, 19:50

question was seen: 1,823 times

last updated: 30 Mar '21, 21:27

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