I have a linestring geometry in my Postgres database. I wanted to extract the latitude-longitude coordinates of each point inside the linestring. Example


Till now, I have executed the query

SELECT st_astext(geometry) from warning_vmz;


"LINESTRING(7.17999 52.66463,7.17899 52.66563,7.17857 52.66604)"
"LINESTRING(7.2860666 53.1664885,7.2860666 53.1664885)"

so I have tried the another function

Select ST_DumpPoints(ST_GeomFromText(st_astext(geometry))) from warning_vmz;



If I use ST_DumpPoints(ST_GeomFromText(geometry)) then I get an error

ERROR:  parse error - invalid geometry
HINT:  "0102000020E6100000711300004C" <-- parse error at position 28 within geometry
********** Error **********

This is a syntax error, try this:

SELECT st_astext(((ST_Dumppoints (geometry)).geom)) as geom from warning_vmz;

note that this line is incorrect, "LINESTRING(7.2860666 53.1664885,7.2860666 53.1664885)" it is wrong, to add the new request to check the geometry for errors Why can PostGIS create LINESTRING from the same values of coordinates of the POINT type?

  • I'm happy for you, keep trying... – Cyril Mikhalchenko Feb 3 '19 at 17:47
  • Thank you, SELECT st_astext(((ST_Dumppoints (geometry)).geom)) as geom from warning_vmz; gives all coordinates from linestring, how can I filter points for each linestring? – Gautam Shahi Feb 3 '19 at 17:51
  • try group by id, it should work – Cyril Mikhalchenko Feb 3 '19 at 17:53
  • I have accepted the answer, thank you. I wanted to create a grid of geographical coordinates 52.36, 9.8 with a distance of 1 km and trying to represent these point, can you please suggest some lead? I am stuck. – Gautam Shahi Feb 3 '19 at 18:38
  • Look at this answer - gis.stackexchange.com/questions/271234/… it will help you solve your problem or look for similar answers, there are enough of them... – Cyril Mikhalchenko Feb 3 '19 at 18:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.