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

I need to be able to populate a database with nodes, ways and intersections/junctions. I've tried a number of approaches so far, without much luck. The closest I've got so far is loading the road shapefile for my region into the database via PostGis. This has given me a table with osm_ids however I'm not entirely sure whether they are node IDs or way IDs.

The issue here is that I require the nodes for the main purpose of the app, however I believe I need the ways in order to detect road intersections/junctions unless there's a way to find a list of junctions within the vicinity of a given node.

The idea is to be given a GPS coordinate and to relate it to node nearest to that location. Once detected, the app would find a list of junctions within X radius of this node.

I'm still very new to OSM as well as spatial databases, so I may have easily missed something along the way. Any help would be greatly appreciated as this critical component is the building block for the rest of this project.

asked 02 Dec '12, 18:03

JuZeeMan's gravatar image

JuZeeMan
41336
accept rate: 0%


This is the third question you're asking here, and all are quite similar, and are essentially about the basics of spatial data processing. You might want to consider reading a book or introductory web site (this OpenGeo workshop is said to be excellent), or else pay someone to solve your problem.

I have already explained to you how you can find nearby roads in my previous answer; now if you want to find intersections there's a number of different things you could do. The simplest is first extracting the roads in the vicinity of your location and then asking PostGIS for intersections which goes something like this:

SELECT 
    st_intersection(a.geom, b.geom)
FROM 
    myroadstable a,
    myroadstable b
WHERE
    [ conditions to select nearby roads from a, b ]
AND
    st_intersects(a.geom, b.geom)

This works even if your database does not have topology, i.e. if you have simply imported a shape file from somewhere. If you have imported an OSM database using Osmosis or osm2pgsql, you could also formulate a more precise query along the lines of "give me all nodes in the vicinity which are a member of two or more highways", thereby avoiding false positives when a road leads over another road in a tunnel/bridge situation.

permanent link

answered 02 Dec '12, 19:20

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

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
×167
×118
×49
×29

question asked: 02 Dec '12, 18:03

question was seen: 6,499 times

last updated: 02 Dec '12, 19:20

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