1

I'm trying to code about how to create isochrones, this is my code:

SELECT i As time_access,
ST_SetSRID(pgr_pointsAsPolygon(
‘SELECT id, ST_X (geom) AS x, ST_Y (geom) As y
FROM dd_caserne
WHERE access_time <= ‘|| i :: text), 4326) As geom
FROM generate_series(60,300,60)
As i
ORDER BY i DESC;

And the error I am getting is as follows:

ERROR:  syntax error at or near "id"
LINE 4: ‘SELECT id, ST_X (geom) AS x, ST_Y (geom) As y

can someone help me ?

Jim Jones
  • 18,404
  • 3
  • 35
  • 44

1 Answers1

0

Welcome to SO.

You're using a wrong character to quote the SELECT string. Use single quotes ' instead of ´:

SELECT 
  i AS time_access,
  ST_SetSRID(pgr_pointsAsPolygon(
    'SELECT id, ST_X(geom) AS x, ST_Y(geom) AS y
     FROM dd_caserne WHERE access_time <= '|| i::text), 4326) AS geom
FROM generate_series(60,300,60) AS i
ORDER BY i DESC;

See also dollar-quoted strings

Note: if you're using pgRouting 3.0+ please check pgr_alphaShape

Jim Jones
  • 18,404
  • 3
  • 35
  • 44
  • Hi Jim, when i use this form it gives me this error : ERROR: function pgr_pointsaspolygon(text) does not exist – lirim bokshi Jun 12 '22 at 10:48
  • @lirimbokshi it is now a totally different issue. If you do have pgrounting installed, can you check if it still has this function? Or maybe use: https://docs.pgrouting.org/3.0/en/pgr_alphaShape.html#pgr-alphashape – Jim Jones Jun 12 '22 at 10:54