Re: [pgrouting-users] PG Routing Question

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: [pgrouting-users] PG Routing Question

Stephen Woodbridge
Hi Andrew,

This is a really good question it gets asked every so often. So I will cc the pgRouting-users list with my response.

The routing algorithm computes the cost to get to each node following the road network. If the cost is time based then it takes the speed of the road segments into account. You can't do meaningful interpolation between points without taking into account the edges. Think about a path following the letter "S" or "C",  interpolation between the end points does not take into account the path of the letter or in our case the roads. Also if you pick two arbitrary nodes they may or may not be connected directly. So interpolation is not going to make sense.

One option might be to examine each edge, and get the values of the their respective nodes, then interpolate along the edge and add the interpolated points into a temporary table, then you can union the original points plus the interpolated points into pgr_pointsAsPolygon()

Another solution that might work for you if you need better resolution but this would be the same as above and require more work, would be to take every edge and break it into 4 equal edges and replace the original edge so that instead of having one edge and 2 node, you now have 4 edges and 5 nodes. Then you can rebuild the topology and your driving distance will have a high density of node.

I hope this helps,
  -Steve

On 9/1/2017 10:52 AM, Andrew Wooley wrote:
Stephen

I attended your workshop at the FOSS4G Boston conference. I really enjoyed it and learned a lot. I have been working on some projects using it.

I came across an issue that I was hoping that you could help me. I am using the following example function from Regina's workshop:

SELECT 
    1 As id, 
    ST_SetSRID(
        pgr_pointsAsPolygon(
            $$
                SELECT D.seq AS id, ST_X(V.the_geom) AS x, ST_Y(V.the_geom) As y 
                FROM 
                    pgr_drivingDistance(
                        $sql$
                            SELECT gid As id, source, target, length_m AS cost, length_m AS reverse_cost FROM osm_ways
                        $sql$,
                        (SELECT id FROM osm_ways_vertices_pgr N ORDER BY N.the_geom <-> ST_SetSRID(ST_Point(-111.69429,40.28984),4326) LIMIT 1), 
                        500, 
                        TRUE
                    ) D INNER JOIN 
                    osm_ways_vertices_pgr V ON D.node = V.id
            $$
        ),
    4326
    ) As the_geom
;

It is selecting the vertices in the table and the creating the polygon. It works well, but I was wondering if there was a strategy for interpolating points along the line to make the distance be the input distance between vertices even if there isn't a vertex there in the table.

Thanks a lot for your help.

Andrew Wooley | IT Director
Mountainland Association of Governments
40.311,-111.682
801-229-3844 



Virus-free. www.avast.com

_______________________________________________
Pgrouting-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/pgrouting-users
Reply | Threaded
Open this post in threaded view
|

Re: [pgrouting-users] PG Routing Question

dkastl
Hi Andrew,

Once I had to route to every point in a virtual raster, which makes sure, that there is a node every few hundred meters.
The first step was to create raster nodes. Then you query for the nearest edge of each raster node.
When you know the edge you can create a link between the raster point and the source and target of this edge and assume some costs to reach the raster node.

Here is a picture, how it would look like:


You could also move the raster nodes onto the nearest edge.
Not sure, if this is useful for your use case, but I thought I share it.

Best regards,
Daniel



On Sat, Sep 2, 2017 at 10:38 PM, Stephen Woodbridge <[hidden email]> wrote:
Hi Andrew,

This is a really good question it gets asked every so often. So I will cc the pgRouting-users list with my response.

The routing algorithm computes the cost to get to each node following the road network. If the cost is time based then it takes the speed of the road segments into account. You can't do meaningful interpolation between points without taking into account the edges. Think about a path following the letter "S" or "C",  interpolation between the end points does not take into account the path of the letter or in our case the roads. Also if you pick two arbitrary nodes they may or may not be connected directly. So interpolation is not going to make sense.

One option might be to examine each edge, and get the values of the their respective nodes, then interpolate along the edge and add the interpolated points into a temporary table, then you can union the original points plus the interpolated points into pgr_pointsAsPolygon()

Another solution that might work for you if you need better resolution but this would be the same as above and require more work, would be to take every edge and break it into 4 equal edges and replace the original edge so that instead of having one edge and 2 node, you now have 4 edges and 5 nodes. Then you can rebuild the topology and your driving distance will have a high density of node.

I hope this helps,
  -Steve

On 9/1/2017 10:52 AM, Andrew Wooley wrote:
Stephen

I attended your workshop at the FOSS4G Boston conference. I really enjoyed it and learned a lot. I have been working on some projects using it.

I came across an issue that I was hoping that you could help me. I am using the following example function from Regina's workshop:

SELECT 
    1 As id, 
    ST_SetSRID(
        pgr_pointsAsPolygon(
            $$
                SELECT D.seq AS id, ST_X(V.the_geom) AS x, ST_Y(V.the_geom) As y 
                FROM 
                    pgr_drivingDistance(
                        $sql$
                            SELECT gid As id, source, target, length_m AS cost, length_m AS reverse_cost FROM osm_ways
                        $sql$,
                        (SELECT id FROM osm_ways_vertices_pgr N ORDER BY N.the_geom <-> ST_SetSRID(ST_Point(-111.69429,40.28984),4326) LIMIT 1), 
                        500, 
                        TRUE
                    ) D INNER JOIN 
                    osm_ways_vertices_pgr V ON D.node = V.id
            $$
        ),
    4326
    ) As the_geom
;

It is selecting the vertices in the table and the creating the polygon. It works well, but I was wondering if there was a strategy for interpolating points along the line to make the distance be the input distance between vertices even if there isn't a vertex there in the table.

Thanks a lot for your help.

Andrew Wooley | IT Director
Mountainland Association of Governments
40.311,-111.682
801-229-3844 



Virus-free. www.avast.com

_______________________________________________
Pgrouting-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/pgrouting-users



--
Georepublic UG & Georepublic Japan
eMail: [hidden email]
Web: https://georepublic.info




_______________________________________________
Pgrouting-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/pgrouting-users
Reply | Threaded
Open this post in threaded view
|

Re: [pgrouting-users] PG Routing Question

Regina Obe
In reply to this post by Stephen Woodbridge

Andrew,

 

Sounds like you are asking for virtual points functionality.

 

In the table we presented I think we had logic to put in edge_id, fraction.  Though we didn't have time to cover it in the workshop so we took it out of the presentation.  I think we still have it in the code.

 

Anyrate if you use those which gives you an interpolated point along the edge, you can use the function:

 

pgr_withPointsDD which works with virtual nodes  instead of pgr_drivingDistance

 

http://docs.pgrouting.org/latest/en/pgr_withPointsDD.html#pgr-withpointsdd

 

 

Hope that helps,

Regina

 

 

 

 

From: Pgrouting-users [mailto:[hidden email]] On Behalf Of Stephen Woodbridge
Sent: Saturday, September 02, 2017 9:39 AM
To: Andrew Wooley <[hidden email]>; pgRouting Users List <[hidden email]>
Subject: Re: [pgrouting-users] PG Routing Question

 

Hi Andrew,

This is a really good question it gets asked every so often. So I will cc the pgRouting-users list with my response.

The routing algorithm computes the cost to get to each node following the road network. If the cost is time based then it takes the speed of the road segments into account. You can't do meaningful interpolation between points without taking into account the edges. Think about a path following the letter "S" or "C",  interpolation between the end points does not take into account the path of the letter or in our case the roads. Also if you pick two arbitrary nodes they may or may not be connected directly. So interpolation is not going to make sense.

One option might be to examine each edge, and get the values of the their respective nodes, then interpolate along the edge and add the interpolated points into a temporary table, then you can union the original points plus the interpolated points into pgr_pointsAsPolygon()

Another solution that might work for you if you need better resolution but this would be the same as above and require more work, would be to take every edge and break it into 4 equal edges and replace the original edge so that instead of having one edge and 2 node, you now have 4 edges and 5 nodes. Then you can rebuild the topology and your driving distance will have a high density of node.

I hope this helps,
  -Steve

On 9/1/2017 10:52 AM, Andrew Wooley wrote:

Stephen

 

I attended your workshop at the FOSS4G Boston conference. I really enjoyed it and learned a lot. I have been working on some projects using it.

 

I came across an issue that I was hoping that you could help me. I am using the following example function from Regina's workshop:

 

SELECT 

    1 As id, 

    ST_SetSRID(

        pgr_pointsAsPolygon(

            $$

                SELECT D.seq AS id, ST_X(V.the_geom) AS x, ST_Y(V.the_geom) As y 

                FROM 

                    pgr_drivingDistance(

                        $sql$

                            SELECT gid As id, source, target, length_m AS cost, length_m AS reverse_cost FROM osm_ways

                        $sql$,

                        (SELECT id FROM osm_ways_vertices_pgr N ORDER BY N.the_geom <-> ST_SetSRID(ST_Point(-111.69429,40.28984),4326) LIMIT 1), 

                        500, 

                        TRUE

                    ) D INNER JOIN 

                    osm_ways_vertices_pgr V ON D.node = V.id

            $$

        ),

    4326

    ) As the_geom

;

 

It is selecting the vertices in the table and the creating the polygon. It works well, but I was wondering if there was a strategy for interpolating points along the line to make the distance be the input distance between vertices even if there isn't a vertex there in the table.

 

Thanks a lot for your help.

 

Andrew Wooley | IT Director

Mountainland Association of Governments

40.311,-111.682

801-229-3844 

 

 

Virus-free. www.avast.com

 


_______________________________________________
Pgrouting-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/pgrouting-users