Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a specific location: lat, lng and accuracy(meters) I want to return a geography object that will represent a polygon that surrounds this point with a given radius that will be equivalent to accuracy (I don't want to use a circle)

postgis code:

SELECT ST_AsText(CAST(ST_Buffer(ST_SetSRID(ST_Point(-74.005847, 40.716862),4326),10) As geography));

returns an object with points such as: (-64.005847 40.71.6862) That are on a huge radius and not 10 meters as requested.

What am I doing wrong here?

share|improve this question
up vote 5 down vote accepted

You need to cast it as Geography before buffering it, not after. As you have it, it's being buffered by 10 map units (degrees) instead of meters because the value returned from ST_SetSRID is a geometry.

SELECT ST_AsText(ST_Buffer(CAST(ST_SetSRID(ST_Point(-74.005847, 40.716862),4326) AS geography),10));

share|improve this answer
Thanks.What about this: ST_AsText(ST_Buffer(ST_MakePoint(longitude, latitude)::geography, accuracy)) . Can you tell which one is better? – Orr Apr 8 '14 at 12:07
@Orr Both should be equivalent, the :: notation is just a PostgreSQL specific shorthand. If you use other databases frequently you may wish to stick with CAST – Evil Genius Apr 8 '14 at 12:16
what is the difference between using ST_SetSRID(ST_Point as you wrote and using ST_MakePoint directly? – Orr Apr 8 '14 at 13:33
@Orr Honestly, I'm not sure :). I could assume that in your example the SRID is being defaulted when you cast (with ::), but I don't really know. – Evil Genius Apr 8 '14 at 13:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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