I spent days looking in all questions here and trying tutorials. I need to build a graph for a region (It will be my input in simulation) I downloaded Postgresql and Postgis and osm2pgsql. Now i can load .osm files into a database. I want to have a complete database with roads ids so i can generate a table of edges and nodes then build my graph
nodes = intersections and edges = roads for a city using python.
Please any detailed help with steps.I saw a lot of keywords (Postgresql/postgis, Networkx, QGIS ..) but i couldn't manage to assemble a good tutorial
I am a very beginner.
Answer
If you're a very beginner you should try this tutorial of osm2po by @Underdark
Osm2po will give you ready to use graph from osm data as sql script file, all you have to do is load it into database via psql -f command.
In this table every single record is edge. Every edge has 2 vertices source and target - coordinations of this points are in column x1,y2 and x2,y2.
If you need seperate table with vertices just run:
create table vertices as
select source as ID, st_makepoint(x1,y1) as geom from edges_table
union
select target as ID, st_makepoint(x2,y2) as geom from edges_table
No comments:
Post a Comment