I have entered the circle in the Geometry type column (name=shape) in my POSTGIS as following:

ST_Buffer(ST_MakePoint($longitude, $latitude)::geography, $radius)::geometry

Then I extracted the centre using:


But it gave me a little different value than that of I entered previously.So Can anybody help me find my mistake.Also I need to extract the radius from above table.

  • How different value? About radius you can use st_maxdistanse and divide by 2 but it will not give you an exact value either. That is because the buffer is just an appriximation of a circle built of a limited number of points. Sep 28, 2014 at 7:50

1 Answer 1


If that code works you are creating a point on a sphere ( ::geography ) the buffering by a radius and requesting it as a shape on a plane ( ::geometry )

Then st_astext converts to wkt, yet more info (inc, any SRID) is returned via the PostGIS ST_AsEWKT calls.

So you have some reading to do: Doc on geography and geometry http://postgis.net/docs/manual-2.1/using_postgis_dbmanagement.html#PostGIS_Geography

Also please confirm that this is code you are using, also if this works it's really strange:

($longitude, $latitude)::geography

As ST_MakePoint doesn't take a geography type, only lat, lon, and z, m. ST_MakePoint

And that's likely to be your problem.

If possible try and perform those commands using pgsql or pgAdmin and then when you know what you are doing recreate them in your php.

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.