<div dir="ltr">Dear all,<br><br>I need to calculate the catchment area for a number of nodes (schools).<br><br>I'm using pgr_driving distance and adding geometry from the nodes table.<br><br>-----<br>My code creates a table for each destination. Example (for node 71197):<br>
<br>drop table if exists contagio71197;<br>create table contagio71197 as<br>SELECT foo.id1 as no, foo.cost as cost71197, vertices_tmp.the_geom<br> FROM vertices_tmp inner join pgr_drivingdistance('<br> SELECT gid AS id,<br>
source,<br> target,<br> tempo::float8 AS cost<br> FROM lisboa',<br> 71197,<br> 20,<br> false,<br> false) as foo<br>on (<a href="http://vertices_tmp.id">vertices_tmp.id</a> = foo.id1);<br>
<br>---------------------------------<br>Now, since I have around 100 destinations, I tried to loop through the list of nodes.<br><br>I wrote the following code (column numero.nn contains the list of nodes which constitute the destinations:<br>
<br>'<br><br>DO $$<br>DECLARE<br> i integer;<br>BEGIN<br>FOR i IN (select nn from numero)<br>LOOP<br>EXECUTE <br>'create table contagio' || i || ' as<br>SELECT id1 as no, cost as cost' || i ||<br>' FROM pgr_drivingdistance('<br>
SELECT gid AS id,<br> source,<br> target,<br> tempo::float8 AS cost<br> FROM lisboa', '<br> || i || ' ,<br> 30,<br> false,<br> false)'<br>;<br>END LOOP;<br>
END; <br>$$;<br><br>---------------------------------------------------------------------------<br><br>Now, I know where the problem is: the query string after EXECUTE has a function that uses another query string as an input (pgr_drivingDistance(text sql, ......)<br>
<br>Probably there's a simple solution, but I can't get it.<br><br>Any help.<br>Thank you very much.<br><br>Carla<br><br><br></div>