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.

  • you might have left out part of the error message; was it invalid input syntax for type double precision: ""? If so, you need to filter these out with WHERE lng <> '' AND lat <> ''.
    – Mike T
    Jul 26, 2015 at 3:08

1 Answer 1


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);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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