Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

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 am trying to follow PostGIS ST_Buffer Radius Help to use a 50 meter distance but postgis is returning an error.

I am trying the following SQL,

SELECT id FROM table 
WHERE ST_DWithin(ST_GeogFromText('SRID=4326;POINT(-3.165356 55.926665)'), 
      geography(geometry), 50);

The hints indicated at ST_GeogFromText are,

  • function st_geogfromtext(unknown) does not exist at character 92
  • No function matches the given name and argument types. You might need to add explicit type casts.

Any help/alternatives would be appreciated.

share|improve this question

You need PostGIS 1.5 or greater to have the geography type. The older versions have the ST_Distance_Spher*() functions, but as you note, they only work for points.

share|improve this answer

As mentioned in docs:

For Geometries: The distance is specified in units defined by the spatial reference system of the geometries.

If your data is in SRID=4326 the distance you are specifying is in radians.

You either have to use ST_Transform and meter based coordinate system, or one of the two functions: ST_Distance_Sphere (faster, less accurate) or ST_Distance_Spheroid.

share|improve this answer
Thank you for your answer. I used the functions above and they indeed return meters but i can only use them to calculate a distance between two latlong geometries and I need to use it to calculate distance from polygon edges. I thought of a solution with the above info, I could use st_closestPoint() to my polygon and then st_distance_sphere() which will do the trick. Problem is I am using postgis 1.4 and st_closestPoint() is unavailable. Also, I would like to use minimum code because ST_WDistance() will return a simple true/false whilst the other alternatives need more coding. – Antony Sep 3 '12 at 15:21

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.