4

I have a table called customer_campaign, and there is an empty column geom(geography) in it. So I want to fill it up by using ST_MakePoint(long, lat) in PostGIS, lat and long are two columns in the customer_campaign table. I tried the following query:

SELECT ST_MakePoint(customer_campaign.long, customer_campaign.lat);

But returns an error. How do I populate geography column with ST_Make(long, lat) in PostGIS ?

1 Answer 1

5

You need to cast from the output of ST_MAKE() which is a geometry to the geography data type.

This casting is done by using the :: operator.

The following command should work: UPDATE customer_campaign set geom=ST_MakePoint(customer_campaign.long, customer_campaign.lat)::geography;

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.