NOTICE: help.openstreetmap.org 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? https://www.openstreetmap.org/relation/2954632

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

mdchachi
26111
accept rate: 0%


Some of this information is available with no programming from the Relation Analyzer tool: http://ra.osmsurround.org/analyzeRelation?relationId=2954632&_noCache=on

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

alan_gr
2.6k12245
accept rate: 15%

I would like to suggest https://overpass-turbo.eu/s/15BQ:

[out:csv(length,highway,oneway)];
relation(2954632)->.parent;
way(r.parent)[oneway=yes];
for (t["highway"])
{
  make stat highway=_.val,oneway=set(t["oneway"]),length=sum(length())/2;
  out;
}
way(r.parent)[oneway!=yes];
for (t["highway"])
{
  make stat highway=_.val,oneway=set(t["oneway"]),length=sum(length());
  out;
}

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
6.7k36489
accept rate: 36%

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×483
×236
×179
×147

question asked: 30 Mar '21, 19:50

question was seen: 2,063 times

last updated: 30 Mar '21, 21:27

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