I am trying to simplify road network with PostGIS. The original network and desired network are illustrated below.
I think I need to do the following manipulations to obtain the desired result:
- Split links which has intersection(s) with other link(s) at the middle (Examples: id4 in the original network which is connedted by id5, id15 which is connected by id20 and id14)
- Merge adjacent links which are connected at the edges, but not at the intersections (such as 1 and 2, 13 and 14, 3 and left side of 4 in the original network)
The desired output may be obtained from the following process:
- Find verteces which are connected to other links
- Split links using the verteces found in the process 1
- Merge links which are NOT connected to more than 3 links
However, as I just started to use PostGIS, I do not have sufficient knowledge for the implementation. I found a similar example here, but it uses join_id
and street
to merge links. My network does not have an identifier for merging links. Geometry information is only the way to identify links to be split/merged.
Here is the original network that I am using in pgAdmin4:
CREATE TABLE net (id integer, geom geometry(MultiLineString, 4326));
INSERT INTO net (id, geom)
VALUES (1, ST_GeomFromText('MULTILINESTRING((136.6196599601392 36.589639081378664,136.61989569531218 36.58965330446509))', 4326)),
(2, ST_GeomFromText('MULTILINESTRING((136.61989569531218 36.58965330446509,136.62012398243598 36.589667078173306))', 4326)),
(3, ST_GeomFromText('MULTILINESTRING((136.62012398243598 36.589667078173306,136.62022166003996 36.5896726469273))', 4326)),
(4, ST_GeomFromText('MULTILINESTRING((136.62022166003996 36.5896726469273,136.6203506286787 36.58967999963244,136.62063360215916 36.58968753774985))', 4326)),
(5, ST_GeomFromText('MULTILINESTRING((136.6203506286787 36.58967999963244,136.62036404026844 36.58954216863634))', 4326)),
(6, ST_GeomFromText('MULTILINESTRING((136.62036404026844 36.58954216863634,136.620421707496 36.589543245124844))', 4326)),
(7, ST_GeomFromText('MULTILINESTRING((136.620421707496 36.589543245124844,136.62049680988002 36.589587394642706))', 4326)),
(8, ST_GeomFromText('MULTILINESTRING((136.62049680988002 36.589587394642706,136.62065237730553 36.589583086890116))', 4326)),
(9, ST_GeomFromText('MULTILINESTRING((136.62063360215916 36.58968753774985,136.62065237730553 36.589583086890116,136.6206638954505 36.589480812069304))', 4326)),
(10,ST_GeomFromText('MULTILINESTRING((136.6206638954505 36.589480812069304,136.62067517601872 36.589380646799555,136.62068188226328 36.589223432715414))', 4326)),
(11,ST_GeomFromText('MULTILINESTRING((136.62068188226328 36.589223432715414,136.62020310748755 36.58920297313887))', 4326)),
(12,ST_GeomFromText('MULTILINESTRING((136.62020310748755 36.58920297313887,136.62016019183955 36.58922666308018))', 4326)),
(13,ST_GeomFromText('MULTILINESTRING((136.62016019183955 36.58922666308018,136.6200241103804 36.589219386818))', 4326)),
(14,ST_GeomFromText('MULTILINESTRING((136.6200241103804 36.589219386818,136.6197417678685 36.589201896650366))', 4326)),
(15,ST_GeomFromText('MULTILINESTRING((136.61954957107096 36.589770977368836,136.619626432514 36.58968753774985,136.6196599601392 36.589639081378664,136.6196867824193 36.58958524076644,136.6197323798457 36.58936126461083,136.6197417678685 36.589201896650366,136.6197447880784 36.58910164634096))', 4326)),
(16,ST_GeomFromText('MULTILINESTRING((136.62013469499337 36.589528238518106,136.62012398243598 36.589667078173306,136.62015751006118 36.58969399847939))', 4326)),
(17,ST_GeomFromText('MULTILINESTRING((136.62015751006118 36.58969399847939,136.6201497449703 36.58981549677306))', 4326)),
(18,ST_GeomFromText('MULTILINESTRING((136.62013469499337 36.589528238518106,136.620149930439 36.58935147252844))', 4326)),
(19,ST_GeomFromText('MULTILINESTRING((136.620149930439 36.58935147252844,136.62016019183955 36.58922666308018))', 4326)),
(20,ST_GeomFromText('MULTILINESTRING((136.6196599601392 36.589639081378664,136.619642525882 36.58963800399084,136.61959358689234 36.58963701183535))', 4326)),
(21,ST_GeomFromText('MULTILINESTRING((136.61959358689234 36.58963701183535,136.61952416180296 36.58963560435872))', 4326)),
(22,ST_GeomFromText('MULTILINESTRING((136.62068188226328 36.589223432715414,136.62068456404154 36.589149132526586,136.62067785869635 36.58911575149091))', 4326)),
(23,ST_GeomFromText('MULTILINESTRING((136.62063360215916 36.58968753774985,136.62062878485793 36.58976023194854))', 4326)),
(24,ST_GeomFromText('MULTILINESTRING((136.62063360215916 36.58968753774985,136.6206888947573 36.589687030307246))', 4326)),
(25,ST_GeomFromText('MULTILINESTRING((136.6206888947573 36.589687030307246,136.62076739174896 36.589686309908515))', 4326))
==== UPDATED =====
The suggested method returned the following network.
It returns the network close to my desired result but it does not split links at intersections: i.e., id15
in the original network should be split at the intersections with id20
and id14
. id19
and id21
also have the same issue.
I suppose it is not taken into account in the suggested method as all links are split at all intersections in their network.