[pgrouting-users] Dangling sub-networks

Hi list

I realize that the network (OSM) I am working on is not always connected as it should (big surprise J)…. Some parts are disjoint from the rest – even when not being situated on islands, or other places where a disjoint is expected. Accordingly, routes from nodes on such sub-nets cannot be generated.

Is there a way to identify (and potentially delete) such minor sub-nets? For instance by asking for the aggregated length of edges of a sub-net.

image003.png

image004.png

image005.png

image006.png

image007.png

image008.png

image009.png

image011.png

···

Hans Skov-Petersen

Professor of Geoinformatics

University of Copenhagen

Department of Geosciences and Natural Resource Management

Section of Landscape Architecture and Planning

Rolighedsvej 23

DK-1958 Frederiksberg

DIR +45 35 33 18 16

MOB +45 23 82 80 45

hsp@ign.ku.dk

Title: SD_Logo

How we protect personal data

Is there a way to identify (and potentially delete) such minor sub-nets?

IMHO: this is similar for detecting “Component” ( https://en.wikipedia.org/wiki/Component_(graph_theory) )
Have you checked the https://docs.pgrouting.org/3.1/en/components-family.html functions?

If you know the components - you can calculate the aggregated length of edges for each component.

Regards,
Imre

Hans Skov-Petersen <hsp@ign.ku.dk> ezt írta (időpont: 2021. jún. 27., V, 21:42):

Hi list

I realize that the network (OSM) I am working on is not always connected as it should (big surprise J)…. Some parts are disjoint from the rest – even when not being situated on islands, or other places where a disjoint is expected. Accordingly, routes from nodes on such sub-nets cannot be generated.

Is there a way to identify (and potentially delete) such minor sub-nets? For instance by asking for the aggregated length of edges of a sub-net.

Hans Skov-Petersen

Professor of Geoinformatics

University of Copenhagen

Department of Geosciences and Natural Resource Management

Section of Landscape Architecture and Planning

Rolighedsvej 23

DK-1958 Frederiksberg

DIR +45 35 33 18 16

MOB +45 23 82 80 45

hsp@ign.ku.dk

Title: SD_Logo

How we protect personal data


Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/pgrouting-users

Hi Imre

It seems like something I can make work to identify small subnets/components. Thanks.

Would you happen to have a hint to how to delete such components from a network/topology?

Cheers

Hans

image010.jpg

image011.png

image003.png

image004.png

image005.png

image006.png

image007.png

image008.png

image009.png

···

Is there a way to identify (and potentially delete) such minor sub-nets?

IMHO: this is similar for detecting “Component” ( https://en.wikipedia.org/wiki/Component_(graph_theory) )

Have you checked the https://docs.pgrouting.org/3.1/en/components-family.html functions?

If you know the components - you can calculate the aggregated length of edges for each component.

Regards,

Imre

Hans Skov-Petersen <hsp@ign.ku.dk> ezt írta (időpont: 2021. jún. 27., V, 21:42):

Hi list

I realize that the network (OSM) I am working on is not always connected as it should (big surprise J)…. Some parts are disjoint from the rest – even when not being situated on islands, or other places where a disjoint is expected. Accordingly, routes from nodes on such sub-nets cannot be generated.

Is there a way to identify (and potentially delete) such minor sub-nets? For instance by asking for the aggregated length of edges of a sub-net.

Hans Skov-Petersen

Professor of Geoinformatics

University of Copenhagen

Department of Geosciences and Natural Resource Management

Section of Landscape Architecture and Planning

Rolighedsvej 23

DK-1958 Frederiksberg

DIR +45 35 33 18 16

MOB +45 23 82 80 45

hsp@ign.ku.dk

Title: SD_Logo

How we protect personal data


Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/pgrouting-users

Would you happen to have a hint to how to delete such components from a network/topology?

my proposal:
-create “components_table”
-insert new column (“component” id ) to the edge_table ( and fill from components_table )

  • calculate sum(cost ) by component … and find the long tails
  • filter OR delete by small component id-s ( I prefer creating new edge table instead of delete … )

– public.edge_table
https://docs.pgrouting.org/3.1/en/sampledata.html

CREATE TABLE components_table as
SELECT * FROM pgr_connectedComponents(
‘SELECT id, source, target, cost, reverse_cost FROM edge_table’
)
;

– add a new column to the edge_table
ALTER TABLE edge_table ADD COLUMN component BIGINT;
UPDATE edge_table as e
SET component = c.component
FROM components_table c
WHERE (e.component is NULL) AND e.source=c.node
;

– calculate small component → sum(cost)
CREATE TABLE small_components as
SELECT component,
sum(cost) as sum_cost
FROM edge_table
GROUP BY 1
HAVING sum(cost) < 2 ;

– create new_edge_table
– filtering: not in small components
CREATE TABLE new_edge_table as
SELECT * FROM edge_table
WHERE component not in ( SELECT component FROM small_components )
ORDER BY id
;

the small_components tables

select * from small_components;
component | sum_cost
-----------±---------
14 | 1
16 | 1
(2 rows)

all components:

SELECT component,
sum(cost) as sum_cost
FROM edge_table
GROUP BY 1
ORDER BY 2 DESC ;

component | sum_cost
-----------±---------
1 | 12
14 | 1
16 | 1
(3 rows)

In your case … probably the cost is "in meter length "

ps:

Regards,

Imre

Hans Skov-Petersen <hsp@ign.ku.dk> ezt írta (időpont: 2021. jún. 27., V, 23:17):

Hi Imre

It seems like something I can make work to identify small subnets/components. Thanks.

Would you happen to have a hint to how to delete such components from a network/topology?

Cheers

Hans

From: Pgrouting-users <pgrouting-users-bounces@lists.osgeo.org> On Behalf Of Imre Samu
Sent: 27. juni 2021 22:59
To: pgRouting users mailing list <pgrouting-users@lists.osgeo.org>
Cc: pgRouting developers mailing list <pgrouting-dev@lists.osgeo.org>
Subject: Re: [pgrouting-users] Dangling sub-networks

Is there a way to identify (and potentially delete) such minor sub-nets?

IMHO: this is similar for detecting “Component” ( https://en.wikipedia.org/wiki/Component_(graph_theory) )

Have you checked the https://docs.pgrouting.org/3.1/en/components-family.html functions?

If you know the components - you can calculate the aggregated length of edges for each component.

Regards,

Imre

Hans Skov-Petersen <hsp@ign.ku.dk> ezt írta (időpont: 2021. jún. 27., V, 21:42):

Hi list

I realize that the network (OSM) I am working on is not always connected as it should (big surprise J)…. Some parts are disjoint from the rest – even when not being situated on islands, or other places where a disjoint is expected. Accordingly, routes from nodes on such sub-nets cannot be generated.

Is there a way to identify (and potentially delete) such minor sub-nets? For instance by asking for the aggregated length of edges of a sub-net.

Hans Skov-Petersen

Professor of Geoinformatics

University of Copenhagen

Department of Geosciences and Natural Resource Management

Section of Landscape Architecture and Planning

Rolighedsvej 23

DK-1958 Frederiksberg

DIR +45 35 33 18 16

MOB +45 23 82 80 45

hsp@ign.ku.dk

Title: SD_Logo

How we protect personal data


Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/pgrouting-users


Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/pgrouting-users

You are a pal.

Thanks

I’ll go for it.

Cheers

Hans Skov-Petersen

Professor of Geoinformatics

University of Copenhagen

Department of Geosciences and Natural Resource Management

Section of Landscape Architecture and Planning

Rolighedsvej 23

DK-1958 Frederiksberg

DIR +45 35 33 18 16

MOB +45 23 82 80 45

hsp@ign.ku.dk

Title: SD_Logo

How we protect personal data

image010.jpg

image011.png

···

Would you happen to have a hint to how to delete such components from a network/topology?

my proposal:

-create “components_table”

-insert new column (“component” id ) to the edge_table ( and fill from components_table )

  • calculate sum(cost ) by component … and find the long tails

  • filter OR delete by small component id-s ( I prefer creating new edge table instead of delete … )

– public.edge_table

https://docs.pgrouting.org/3.1/en/sampledata.html

CREATE TABLE components_table as
SELECT * FROM pgr_connectedComponents(
‘SELECT id, source, target, cost, reverse_cost FROM edge_table’
)
;

– add a new column to the edge_table
ALTER TABLE edge_table ADD COLUMN component BIGINT;
UPDATE edge_table as e
SET component = c.component
FROM components_table c
WHERE (e.component is NULL) AND e.source=c.node

;

– calculate small component → sum(cost)

CREATE TABLE small_components as
SELECT component,
sum(cost) as sum_cost
FROM edge_table
GROUP BY 1
HAVING sum(cost) < 2 ;

– create new_edge_table
– filtering: not in small components
CREATE TABLE new_edge_table as
SELECT * FROM edge_table
WHERE component not in ( SELECT component FROM small_components )
ORDER BY id
;

the small_components tables

select * from small_components;
component | sum_cost
-----------±---------
14 | 1
16 | 1
(2 rows)

all components:

SELECT component,
sum(cost) as sum_cost
FROM edge_table
GROUP BY 1
ORDER BY 2 DESC ;

component | sum_cost
-----------±---------
1 | 12
14 | 1
16 | 1
(3 rows)

In your case … probably the cost is "in meter length "

ps:

Regards,

Imre

Hans Skov-Petersen <hsp@ign.ku.dk> ezt írta (időpont: 2021. jún. 27., V, 23:17):

Hi Imre

It seems like something I can make work to identify small subnets/components. Thanks.

Would you happen to have a hint to how to delete such components from a network/topology?

Cheers

Hans

From: Pgrouting-users <pgrouting-users-bounces@lists.osgeo.org> On Behalf Of Imre Samu
Sent: 27. juni 2021 22:59
To: pgRouting users mailing list <pgrouting-users@lists.osgeo.org>
Cc: pgRouting developers mailing list <pgrouting-dev@lists.osgeo.org>
Subject: Re: [pgrouting-users] Dangling sub-networks

Is there a way to identify (and potentially delete) such minor sub-nets?

IMHO: this is similar for detecting “Component” ( https://en.wikipedia.org/wiki/Component_(graph_theory) )

Have you checked the https://docs.pgrouting.org/3.1/en/components-family.html functions?

If you know the components - you can calculate the aggregated length of edges for each component.

Regards,

Imre

Hans Skov-Petersen <hsp@ign.ku.dk> ezt írta (időpont: 2021. jún. 27., V, 21:42):

Hi list

I realize that the network (OSM) I am working on is not always connected as it should (big surprise J)…. Some parts are disjoint from the rest – even when not being situated on islands, or other places where a disjoint is expected. Accordingly, routes from nodes on such sub-nets cannot be generated.

Is there a way to identify (and potentially delete) such minor sub-nets? For instance by asking for the aggregated length of edges of a sub-net.

Hans Skov-Petersen

Professor of Geoinformatics

University of Copenhagen

Department of Geosciences and Natural Resource Management

Section of Landscape Architecture and Planning

Rolighedsvej 23

DK-1958 Frederiksberg

DIR +45 35 33 18 16

MOB +45 23 82 80 45

hsp@ign.ku.dk

Title: SD_Logo

How we protect personal data


Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/pgrouting-users


Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/pgrouting-users