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

Some trunk roads have multiple ways (oneway=true), how would you go about measure the length of such a road without counting those portions twice ?

asked 23 Apr '13, 17:45

pgirolami76's gravatar image

pgirolami76
16112
accept rate: 0%

edited 23 Apr '13, 19:35


Perhaps the easiest option is to use a routing engine (such as OSRM); route from the start to the end of the road (which will probably prefer trunk roads on its default profile); and measure the length of the result. The OSRM demo site will tell you the distance, or you could analyse the GPX export. You could, of course, use your own OSRM instance or the public API.

permanent link

answered 23 Apr '13, 17:56

Richard's gravatar image

Richard ♦
30.9k44279412
accept rate: 18%

If you load the data into a PostGIS database (e.g. with osm2pgsql) then you can conceivably run an operation like "draw an area of 50 metres around each bit of a trunk road; if another bit of trunk road falls within that area, delete it". (The relevant PostGIS functions to look up are ST_BUFFER and ST_CONTAINS or ST_INTERSECTS.) This will never give a perfect result since you would wrongly keep those lanes that are more than 50 metres apart, and you would wrongly drop bits that run really close to another trunk road, but you'd probably arrive at a relatively good measure.

(Btw. if you have the stuff in PostGIS anyway, it is dead easy to compute the length by using ST_LENGTH on a GEOGRAPHY data type.)

permanent link

answered 23 Apr '13, 18:51

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

Yes everything is in postgis and we're working with a treillis. What I want is to know the length of the roads inside each treillis square. The issue here is that for 2-way roads, I'll count twice the length and that's incorrect.

(23 Apr '13, 19:32) pgirolami76

As I said - compute a buffer around each road and delete others inside that buffer, that should get rid of the 2-way roads.

(24 Apr '13, 07:18) Frederik Ramm ♦

Can you explain a little more ? How would I create the shape for that road to buffer around if I can't distinguish the ways ?

(24 Apr '13, 17:20) pgirolami76

Ok, I understand better : you're saying eliminate all the other roads and that will get rid of the other way. But I'm interested in computing the intersected length of all road segments per category (primary, secondary, tertiary) so that wouldn't work. It would however help if I precomputed each road and if I kept in each square only the longest segment per road (=per ref). Is that your idea or was it something else ?

(25 Apr '13, 07:43) pgirolami76

There was a proposal to join the two carriageways into a dual_carriageway relation. This would assist with your question (if in a DC relation only measure one way or the average of the two). It would also assist with the application of maxspeed=national to know difference between a single or dual carriage road without the kludge of adding maxspeed=70 mph / 60 mph when the sign says national speed limit not 60 or 70 mph.

permanent link

answered 23 Apr '13, 18:32

ChrisH's gravatar image

ChrisH
4.1k134262
accept rate: 15%

yes it would. As would assigning a direction to the ways. Did that ever make any progress ? What was blocking it ?

(23 Apr '13, 19:33) pgirolami76

Everything in OSM is voluntary, including tagging. I used the relation a little but it didn't catch on so it is not used now AFAIK.

(23 Apr '13, 19:45) ChrisH

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:

×86

question asked: 23 Apr '13, 17:45

question was seen: 11,953 times

last updated: 25 Apr '13, 07:43

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