[pgrouting-users] Create network with nodes at least every 50m

Hi,

I have spent over a week trying to work this out. I have an existing road network and have used pgr_alphashape to try and get a 400m walking catchment from bus stops.

But pgr_alphashape snapes to the nearest network node which means catchments returned are significantly smaller than 400m. I have therefore tried to create a new network with nodes every 50m using ST_Segmentize but I can’t seem to get it to work.

The function below is my attempt to loop through the existing network and run ST_Segmentize on each entry to return updated network with additional nodes but it only returns one record each time rather than a number of segmented entries.

Any advice on how to make this work or alternative approach would be greately appreciated (especially given that following over a week and research it seems no one else has had this problem).

Regards
Adam

DROP FUNCTION hutt_pax.my_test_function();
CREATE OR REPLACE FUNCTION hutt_pax.my_test_function()
RETURNS TABLE (
xid integer,
xgeog geometry) AS
$BODY$
DECLARE
r hutt_pax.roads_wainuiomata%ROWTYPE;
BEGIN
FOR r IN
SELECT *
FROM hutt_pax.roads_wainuiomata
LOOP

xid := r.id;
xgeog := ST_Segmentize(
r.geom,
0.050
);

RETURN NEXT;

END LOOP;

RETURN NEXT; – return final result

END;
$BODY$ LANGUAGE plpgsql STABLE;

SELECT *
FROM hutt_pax.my_test_function();

Hi Adam,

ST_Segmentize returns a multilinestring and pgrouting does not know what to do with them so it takes only the first segment and ignores the rest.

  http://postgis.refractions.net/docs/ST_Segmentize.html

You will need to explode the into multiple linestrings. look at

  http://postgis.refractions.net/docs/ST_Dump.html

for how to do that.

What you probably should do is something like:

1. create a new edge table
2. process all you edges with segmentize and dump into the new table
3. then run pgr_createTopology on the new table
4. then try to route against the new table

-Steve

On 8/23/2014 8:16 PM, Adam Lawrence wrote:

Hi,

I have spent over a week trying to work this out. I have an existing
road network and have used pgr_alphashape to try and get a 400m walking
catchment from bus stops.

But pgr_alphashape snapes to the nearest network node which means
catchments returned are significantly smaller than 400m. I have
therefore tried to create a new network with nodes every 50m using
ST_Segmentize but I can't seem to get it to work.

The function below is my attempt to loop through the existing network
and run ST_Segmentize on each entry to return updated network with
additional nodes but it only returns one record each time rather than a
number of segmented entries.

Any advice on how to make this work or alternative approach would be
greately appreciated (especially given that following over a week and
research it seems no one else has had this problem).

Regards
Adam

DROP FUNCTION hutt_pax.my_test_function();
CREATE OR REPLACE FUNCTION hutt_pax.my_test_function()
   RETURNS TABLE (
xid integer,
xgeog geometry) AS
$BODY$
DECLARE
     r hutt_pax.roads_wainuiomata%ROWTYPE;
BEGIN
FOR r IN
SELECT *
FROM hutt_pax.roads_wainuiomata
LOOP

xid := r.id <http://r.id>;
xgeog := ST_Segmentize(
r.geom,
0.050
);

RETURN NEXT;
END LOOP;

RETURN NEXT; -- return final result

END;
$BODY$ LANGUAGE plpgsql STABLE;

SELECT *
FROM hutt_pax.my_test_function();

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

Also, there has been work on queries using pgr_drivingDistance that will return partial edges if the next node is not within the distance. These functions will return all the segments you want and then you could use st_convexHull to get a polygon of the catchment area.

https://github.com/GregersP/networkReach

https://github.com/iant1212/networkReach

···

On Sat, Aug 23, 2014 at 10:31 PM, Stephen Woodbridge <woodbri@swoodbridge.com> wrote:

Hi Adam,

ST_Segmentize returns a multilinestring and pgrouting does not know what to do with them so it takes only the first segment and ignores the rest.

http://postgis.refractions.net/docs/ST_Segmentize.html

You will need to explode the into multiple linestrings. look at

http://postgis.refractions.net/docs/ST_Dump.html

for how to do that.

What you probably should do is something like:

  1. create a new edge table
  2. process all you edges with segmentize and dump into the new table
  3. then run pgr_createTopology on the new table
  4. then try to route against the new table

-Steve

On 8/23/2014 8:16 PM, Adam Lawrence wrote:

Hi,

I have spent over a week trying to work this out. I have an existing
road network and have used pgr_alphashape to try and get a 400m walking
catchment from bus stops.

But pgr_alphashape snapes to the nearest network node which means
catchments returned are significantly smaller than 400m. I have
therefore tried to create a new network with nodes every 50m using
ST_Segmentize but I can’t seem to get it to work.

The function below is my attempt to loop through the existing network
and run ST_Segmentize on each entry to return updated network with
additional nodes but it only returns one record each time rather than a
number of segmented entries.

Any advice on how to make this work or alternative approach would be
greately appreciated (especially given that following over a week and
research it seems no one else has had this problem).

Regards
Adam

DROP FUNCTION hutt_pax.my_test_function();
CREATE OR REPLACE FUNCTION hutt_pax.my_test_function()
RETURNS TABLE (
xid integer,
xgeog geometry) AS
$BODY$
DECLARE
r hutt_pax.roads_wainuiomata%ROWTYPE;
BEGIN
FOR r IN
SELECT *
FROM hutt_pax.roads_wainuiomata
LOOP

xid := r.id <http://r.id>;

xgeog := ST_Segmentize(
r.geom,
0.050
);

RETURN NEXT;
END LOOP;

RETURN NEXT; – return final result

END;
$BODY$ LANGUAGE plpgsql STABLE;

SELECT *
FROM hutt_pax.my_test_function();


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


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