Hi, I greatly need your explanation. I am working on a project and i am to identify all the roads in a particular area. For each of the roads, i'm to identify and list out all the intersections in order. I donot really know how go about this. Please can somebody give me an explanation? Thanks

asked 26 Jan, 20:37

Segunlakata's gravatar image

Segunlakata
11138
accept rate: 0%


This will require some amount of programming. There isn't a web service that does this work for you.

First you must understand that roads can be split into many segments in OSM. The geometry of a street in OSM is represented by nodes with coordinates. Where two streets intersect, they will share the same node.

Hence, one possible approach is:

  1. download OSM data for the region of interest.
  2. look at the "way" objects; throw away anything that is not a highway; then combine ways into clusters that have the same street name and where one way ends with the same node the other way begins with, so that you end up with just one way for every street instead of potentially several.
  3. each way consists of several nodes; build an in-memory index that quickly gives you the way for a given node id.
  4. now iterate over all ways, traversing them from westernmost to easternmost node, or whatever makes sense for you, and for each node you encounter, check (using your index) if this node is also in another way than the one you're traversing. if yes, you have found an intersection.

Other possible approaches, if you are more comfortable with that, include loading the data into PostGIS and doing everything with SQL commands.

permanent link

answered 27 Jan, 08:28

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
79.5k906991230
accept rate: 23%

Thank you for your response @Frederik Ramm. Your feedback has been very helpful. Can you please re-explain this your statement..."then combine ways into clusters that have the same street name and where one way ends with the same node the other way begins with, so that you end up with just one way for every street instead of potentially several". I am confused. Should I combine all the ways (e.g. highway) irrespective of the street name as one way should I group the the ways based on the street names?

What I did is this. I combined "ways" with the same street name as one way. I then Iterated through the way for a repeated node id, which i assume should be the intersections. I got some results. But while testing the coordinates directly, some of the coordinates were not pointing to intersections on the OpenStreetMap. Is there anything I'm missing?

Thanks

(31 Jan, 15:01) Segunlakata

Yes, using the name as a grouping feature was a good idea. -- Is it possible that you have somehow retained the duplicate nodes that occur where one segment of a street ends and another of the same street begins? Those could be anywhere, not just at intersections, are they maybe responsible?

(31 Jan, 18:52) Frederik Ramm ♦

Expanding on Frederik's comment, perhaps you have misunderstood the meaning of the segments (ways) that make up a single named street? They do not (in general) correspond to segments between intersections. A street may be split into multiple ways in the data wherever any mapped property of the street changes: the number of lanes, the presence or absence of sidewalks, and so on. Sometimes these coincide with intersections, but often they don't.

(31 Jan, 19:50) alan_gr
Your answer
toggle preview

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:

×12

question asked: 26 Jan, 20:37

question was seen: 257 times

last updated: 31 Jan, 19:50

powered by OSQA