Based on your previous question, ea.region
appears to be text that looks like:
((-79.4609576808001,43.9726680183837))
The parse error or your processed data
is obvious if you look at the value of your attempt:
'POINT(-79.4609576808001 43.9726680183837)'
which is invalid because it has single quotes on each side. This is the same as attempting:
select ST_GeomFromText($$'POINT(-79.4609576808001 43.9726680183837)'$$);
Furthermore, the query can be simplified by using ||
instead of concat
, and just using substr
if you know to only trim off the first and last characters:
SELECT
region,
'POINT' || replace(substr(region, 2, length(region) - 2), ',', ' ') AS correct,
ST_GeomFromText('POINT' ||
replace(substr(region, 2, length(region) - 2), ',', ' '), 4326) AS geom
FROM
(SELECT 326816 AS id,
'((-79.4609576808001,43.9726680183837))'::text AS region) AS ea
WHERE ea.id=326816;
-[ RECORD 1 ]-----------------------------------------------
region | ((-79.4609576808001,43.9726680183837))
correct | POINT(-79.4609576808001 43.9726680183837)
geom | 0101000020E610000018F8A45480DD53C05C69B86280FC4540