[GIS] Invalid Input Syntax for Type Double Precision in PostGIS

postgispostgresql

I have this query that is trying to update my geom column that's built off of lat and lng coordinates

UPDATE main_table SET geom = ST_SetSRID(ST_MakePoint(lng, lat) ,4326);

However it returns that function st_makepoint(text, text) does not exist and gives me a hint to add explicit type casts, so I updated my query to

UPDATE main_table SET geom = ST_SetSRID(
ST_MakePoint(lng:: double precision, lat:: double precision) ,4326);

And now it's throwing an error invalid input syntax for type double precision:.

Just a note, right now my lats and longs are stored as text because I had to use a pg restore to load the table, so I'm sure that's where the problem is but don't know how to address it.

Best Answer

No space should be (also float8 is the same as double precision and a bit faster to type)

UPDATE main_table SET geom = ST_SetSRID(
  ST_MakePoint(lng::float8, lat::float8) ,4326);