9

I have a Shapefile (consisting of European major roads) with about 250.000 Segments which I have to simplify for pgrouting. But I can't seem to find a way to do that properly.

This is what it looks like:

https://i.sstatic.net/qJ2OJ.png

and this is what it should look like:

https://i.sstatic.net/FN4Z6.png

I somehow have to remove every Point of the Lines which is connected to less than 3 Lines (being not an intersection) while preserving the topological connections between the remaining points. If anybody has an idea, it would be greatly appreciated!

I tried to implement the idea of @dkastl and managed to get only the unneccessary nodes (nodes with only 2 adjacent linestrings) from my network with the code below (network generation taken from underdark's blog http://underdark.wordpress.com/2011/02/07/a-beginners-guide-to-pgrouting/):

SELECT * FROM (SELECT tmp.id as gid, node.the_geom FROM (SELECT id, count(*) FROM network JOIN node ON (start_id = id OR end_id = id) AND (end_id = id OR start_id = id) GROUP BY id ORDER BY id) as tmp JOIN node ON (tmp.id = node.id) WHERE tmp.count = 2) as unn_node; 

So, all I now have to do is the merging of the lines. However, I have no clue how. I imagine it has to be a loop which for every row of the result of above query gets the adjacent lines and merges them. Then it would rebuild the network completely and repeat the process until the query above returns an empty result.

0

1 Answer 1

4

You should certainly apply a ramer-douglass-peucker filter to your lines. It is available in PostGIS as the ST_Simplify function. The version with topology preservation may be of interest for your case.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.