<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"Century Gothic";
        panose-1:2 11 5 2 2 2 2 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Century Gothic","sans-serif";
        color:#1F497D;
        font-weight:normal;
        font-style:normal;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";
        mso-fareast-language:EN-GB;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-GB" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:13.0pt;font-family:"Century Gothic","sans-serif";color:#1F497D">Hello Simon<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:13.0pt;font-family:"Century Gothic","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:13.0pt;font-family:"Century Gothic","sans-serif";color:#1F497D">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.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:13.0pt;font-family:"Century Gothic","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:13.0pt;font-family:"Century Gothic","sans-serif";color:#1F497D">As an aside:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:13.0pt;font-family:"Century Gothic","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:13.0pt;font-family:"Century Gothic","sans-serif";color:#1F497D">Look at this post:
<a href="http://anitagraser.com/2011/09/25/a-closer-look-at-alpha-shapes-in-pgrouting/">
http://anitagraser.com/2011/09/25/a-closer-look-at-alpha-shapes-in-pgrouting/</a>
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:13.0pt;font-family:"Century Gothic","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:13.0pt;font-family:"Century Gothic","sans-serif";color:#1F497D">And maybe at this post:
<a href="http://anitagraser.com/2013/07/07/public-transport-isochrones-with-pgrouting/">
http://anitagraser.com/2013/07/07/public-transport-isochrones-with-pgrouting/</a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:13.0pt;font-family:"Century Gothic","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:13.0pt;font-family:"Century Gothic","sans-serif";color:#1F497D">That should help you create the polygons from driving distance.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:13.0pt;font-family:"Century Gothic","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:13.0pt;font-family:"Century Gothic","sans-serif";color:#1F497D">Ross<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:13.0pt;font-family:"Century Gothic","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:13.0pt;font-family:"Century Gothic","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">
<a href="mailto:pgrouting-users-bounces@lists.osgeo.org">pgrouting-users-bounces@lists.osgeo.org</a> [<a href="mailto:pgrouting-users-bounces@lists.osgeo.org">mailto:pgrouting-users-bounces@lists.osgeo.org</a>]
<b>On Behalf Of </b>Simon Georget<br>
<b>Sent:</b> 13 May 2015 18:48<br>
<b>To:</b> <a href="mailto:pgrouting-users@lists.osgeo.org">pgrouting-users@lists.osgeo.org</a><br>
<b>Subject:</b> [pgrouting-users] Isochrones as polygons<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Hi list,<o:p></o:p></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt">I'm trying to generate isochrones as polygons in the way it is explained in that post  :<br>
<br>
<a href="https://smathermather.wordpress.com/2014/08/06/drivetime-analyses-pgrouting/">https://smathermather.wordpress.com/2014/08/06/drivetime-analyses-pgrouting/</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">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.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><o:p> </o:p></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt">I'm able to generate the drivingDistance() but I get lost when trying to get points to generate my polygons.<o:p></o:p></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Is there any sample script somewhere combining the use of pgr_drivingDistance() with pgr_pointsAsPolygon() ?<o:p></o:p></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Here is an attempt to adapt the script from smathermather with my data. Note that I want to run it on multiple start points :<br>
<br>
<br>
---------------------<br>
CREATE OR REPLACE FUNCTION nn_search (geom geometry) RETURNS<br>
int8 AS $$<br>
 <br>
SELECT id FROM roads_idf_l93_vertices_pgr AS r<br>
ORDER BY geom <#> r.the_geom<br>
LIMIT 1;<br>
 <br>
$$ LANGUAGE SQL VOLATILE;<br>
<br>
<br>
-- cette fonction renvoie un polygone<br>
-- elle prend en paramètre l'id du noeud et le cost<br>
CREATE OR REPLACE FUNCTION alpha_shape (id integer, cost integer) RETURNS<br>
geometry AS $$<br>
 <br>
WITH alphashape AS(SELECT pgr_alphaShape('WITH<br>
<br>
DD AS (<br>
    SELECT seq, id1 AS node, cost<br>
    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)<br>
    ),<br>
<br>
points AS (<br>
    SELECT v.id::int4 AS id, x::float8, y::float8<br>
    FROM roads_idf_l93_vertices_pgr v, DD d<br>
    WHERE <a href="http://v.id">v.id</a> = d.node)<br>
    <br>
SELECT * FROM points')),<br>
 <br>
alphapoints AS (<br>
SELECT ST_Makepoint((pgr_alphashape).x, (pgr_alphashape).y) FROM alphashape),<br>
 <br>
alphaline AS (<br>
SELECT ST_MakeLine(ST_MakePoint) FROM alphapoints)<br>
 <br>
SELECT ST_MakePolygon(ST_AddPoint(ST_MakeLine, ST_StartPoint(ST_MakeLine))) AS the_geom FROM alphaline<br>
 <br>
$$ LANGUAGE SQL VOLATILE;<br>
<br>
CREATE TABLE alpha_test AS<br>
WITH dest_ids AS (<br>
SELECT nn_search(geom) AS id FROM gare_idf_l93<br>
)<br>
-- cost 1000 m<br>
SELECT alpha_shape(id::int, 1000)::geometry, id FROM dest_ids;<br>
<br>
-----------------------<o:p></o:p></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Executing this script return the following error :
<br>
<br>
ERROR:  Distance is too short. only 2 vertices for alpha shape calculation. alpha shape calculation needs at least 3 vertices.<br>
CONTEXT:  SQL function "alpha_shape" statement 1<br>
********** Erreur **********<br>
<br>
ERROR: Distance is too short. only 2 vertices for alpha shape calculation. alpha shape calculation needs at least 3 vertices.<br>
État SQL :XX000<br>
Contexte : SQL function "alpha_shape" statement 1<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Any help would be appreciated. Thanks<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">simo<o:p></o:p></p>
</div>
</div>
</div>
<div> </div>
<div>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span style="FONT-SIZE: 7.5pt; FONT-FAMILY: 'Arial','sans-serif'; mso-bidi-font-size: 8.0pt; mso-bidi-font-family: 'Times New Roman'"><font size="2">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.<span style="mso-spacerun: yes">
</span>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.
</font></span></p>
</div>
</body>
</html>