[pgrouting-users] Isochrones as polygons

McDonaldR McDonaldR at angus.gov.uk
Thu May 14 03:11:43 PDT 2015


Hello Simon

Have you tried increasing your distance to 10000?  The error message says your distance is too short and not enough points are available to create the alphashape.

As an aside:

Look at this post: http://anitagraser.com/2011/09/25/a-closer-look-at-alpha-shapes-in-pgrouting/

And maybe at this post: http://anitagraser.com/2013/07/07/public-transport-isochrones-with-pgrouting/

That should help you create the polygons from driving distance.

Ross


From: pgrouting-users-bounces at lists.osgeo.org<mailto:pgrouting-users-bounces at lists.osgeo.org> [mailto:pgrouting-users-bounces at lists.osgeo.org] On Behalf Of Simon Georget
Sent: 13 May 2015 18:48
To: pgrouting-users at lists.osgeo.org<mailto:pgrouting-users at lists.osgeo.org>
Subject: [pgrouting-users] Isochrones as polygons

Hi list,
I'm trying to generate isochrones as polygons in the way it is explained in that post  :

https://smathermather.wordpress.com/2014/08/06/drivetime-analyses-pgrouting/

I'm not familiar with postgres/postgis and I get a bit confused when trying to understand the difference between pgr_alphashape() / pgr_pointsAsPolygon(). I've read a lot through the web but did not find lot of examples scirpts.

I'm able to generate the drivingDistance() but I get lost when trying to get points to generate my polygons.
Is there any sample script somewhere combining the use of pgr_drivingDistance() with pgr_pointsAsPolygon() ?
Here is an attempt to adapt the script from smathermather with my data. Note that I want to run it on multiple start points :


---------------------
CREATE OR REPLACE FUNCTION nn_search (geom geometry) RETURNS
int8 AS $$

SELECT id FROM roads_idf_l93_vertices_pgr AS r
ORDER BY geom <#> r.the_geom
LIMIT 1;

$$ LANGUAGE SQL VOLATILE;


-- cette fonction renvoie un polygone
-- elle prend en paramètre l'id du noeud et le cost
CREATE OR REPLACE FUNCTION alpha_shape (id integer, cost integer) RETURNS
geometry AS $$

WITH alphashape AS(SELECT pgr_alphaShape('WITH

DD AS (
    SELECT seq, id1 AS node, cost
    FROM pgr_drivingDistance(''SELECT id, source::int4 AS source, target::int4 AS target, length::float8 AS cost FROM roads_idf_l93'',' || id || ', ' || cost || ', false, false)
    ),

points AS (
    SELECT v.id::int4 AS id, x::float8, y::float8
    FROM roads_idf_l93_vertices_pgr v, DD d
    WHERE v.id<http://v.id> = d.node)

SELECT * FROM points')),

alphapoints AS (
SELECT ST_Makepoint((pgr_alphashape).x, (pgr_alphashape).y) FROM alphashape),

alphaline AS (
SELECT ST_MakeLine(ST_MakePoint) FROM alphapoints)

SELECT ST_MakePolygon(ST_AddPoint(ST_MakeLine, ST_StartPoint(ST_MakeLine))) AS the_geom FROM alphaline

$$ LANGUAGE SQL VOLATILE;

CREATE TABLE alpha_test AS
WITH dest_ids AS (
SELECT nn_search(geom) AS id FROM gare_idf_l93
)
-- cost 1000 m
SELECT alpha_shape(id::int, 1000)::geometry, id FROM dest_ids;

-----------------------
Executing this script return the following error :

ERROR:  Distance is too short. only 2 vertices for alpha shape calculation. alpha shape calculation needs at least 3 vertices.
CONTEXT:  SQL function "alpha_shape" statement 1
********** Erreur **********

ERROR: Distance is too short. only 2 vertices for alpha shape calculation. alpha shape calculation needs at least 3 vertices.
État SQL :XX000
Contexte : SQL function "alpha_shape" statement 1

Any help would be appreciated. Thanks
simo

This message is strictly confidential. If you have received this in error, please inform the sender and remove it from your system. If received in error you may not copy, print, forward or use it or any attachment in any way. This message is not capable of creating a legal contract or a binding representation and does not represent the views of Angus Council. Emails may be monitored for security and network management reasons. Messages containing inappropriate content may be intercepted. Angus Council does not accept any liability for any harm that may be caused to the recipient system or data on it by this message or any attachment.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/pgrouting-users/attachments/20150514/3b171233/attachment.html>


More information about the Pgrouting-users mailing list