Converting lat long strings to xy linestrings

by SuperPirat0s   Last Updated June 12, 2019 07:22 AM

In PostGIS I have a dataset with road segments including a column with coordinates for the various segments. The coordinates are in a lat long format and the data type of the column is character varying, plus it contains varying number of coordinates in each row (see attached image).

Screenshot of coordinates column in PostGIS

What I wish to do is to be able to show the segments as geometric linestrings in order to later match them to a road network and/or a map.

I've already tried using ST_GeomFromText (see below) and ST_DumpPoint, but without any luck.

SELECT ST_GeomFromText('LINESTRING('||coordinates||')') as geom FROM vejnet.segmentnetdatex2format;

Wich result in the following error code

ERROR: parse error - invalid geometry HINT: "LINESTRING(55.67258,1" <-- parse error at position 21 within geometry SQL state: XX000

I'm still fairly new to PostGIS and working with GIS/spatial data in general, so any help would really be appreciated.



Related Questions


Updated November 12, 2018 18:22 PM

Updated April 19, 2019 08:22 AM

Updated July 18, 2018 23:22 PM

Updated July 06, 2018 15:22 PM

Updated October 16, 2018 07:22 AM