This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

How to query a relation (route) for details?

1

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%


2 Answers:

1

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.

answered 30 Mar '21, 21:10

alan_gr's gravatar image

alan_gr
2.6k12245
accept rate: 15%

1

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.

answered 30 Mar '21, 21:27

Roland%20Olbricht's gravatar image

Roland Olbricht
6.7k36489
accept rate: 36%

Source code available on GitHub .