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

I've extracted a number of streets out of OpenStreetMap. I've found that some streets are great to work with, and others cannot be displayed in a polyline format because their coordinates are out of order.

Here's an example of a good street: good street

The line (on the left, obviously) matches the coordinates (on the right), and looks the way you'd expect it to.

Here's an example of a bad street: bad street

The coordinates (on the bottom left) seem just fine, but once I try to make a polyline out of them (top right) things go crazy.

I think it's because the coordinates (the node entries, from OpenStreetMap) are out of order.

Is this a common issue? Is there a way to correct it?

(The imgur link for the image set is http://imgur.com/a/dvD3M - I'm not sure if the individual image links used above will ever change.)

asked 31 Oct '15, 00:25

JamesChevalier's gravatar image

JamesChevalier
1517713
accept rate: 25%

edited 31 Oct '15, 00:34


As user_5359 suggests, nodes are only ordered within each Openstreetmap way. Your lower image contains multiple ways starting with

http://www.openstreetmap.org/way/8766694 in the north, then

http://www.openstreetmap.org/way/8767452

http://www.openstreetmap.org/way/101458166

http://www.openstreetmap.org/way/101458163

http://www.openstreetmap.org/way/8768186

after which it gets a bit more complicated as there are dual carriageway sections with one way in each direction (both of which join to that last way I mentioned).

http://www.openstreetmap.org/way/8767828

http://www.openstreetmap.org/way/33824767

If you are trying to draw a route you will need to select the ways that are needed depending on direction of travel, in the correct order, and depending which way the way nodes are ordered you may need to reverse the list for individual ways. In the above example if you were heading north from the one way section you might also want to exclude the section of way 8768186 that you wouldn't travel on when you turn left onto it (most routers pre-process the data I believe).

permanent link

answered 31 Oct '15, 07:50

EdLoach's gravatar image

EdLoach ♦
19.5k16156280
accept rate: 22%

edited 31 Oct '15, 07:50

1

That's the problem! I imported all the individual ways into my database as one one single street object. That works perfectly for my underlying use case, but really jams things up when I try to display them on a map. I kept the OSM ID for each node ... I wonder if there's a way for me to piece together the separate sections with that data ...

(31 Oct '15, 20:10) JamesChevalier
2

You really have to reassemble street objects from OSM ways: you cant just treat them as a multilinestring. They need to be manipulated as a graph (which is what most routing software does).

(31 Oct '15, 20:28) SK53 ♦

Is that really just one OSM way? The nodes are sorted only within an OSM way. Can you tell us the OSM Way ID, please?

permanent link

answered 31 Oct '15, 04:16

user_5359's gravatar image

user_5359
91117
accept rate: 0%

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:

×205
×17
×8

question asked: 31 Oct '15, 00:25

question was seen: 3,693 times

last updated: 31 Oct '15, 20:28

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