I am storing OS Open Local data, as downloaded here: https://www.ordnancesurvey.co.uk/opendatadownload/products.html (top result).

In particular my geometry column takes one of two possible shapes:

SELECT ST_AsGeoJSON(geometry) FROM roads LIMIT 1;

Resulting in:



 SELECT ST_AsGeoJSON(geometry) FROM buildings LIMIT 1;

Resulting in:


Given a lat, a long, and a radius in meters, how would I SELECT all roads or buildings which are either contained by, or intersect the selected circle?


1 Answer 1


Because the use of ST_Buffer/St_Intersects is really undesired here, I post another option with the use of only ST_DWithin. The advantage is a much faster and more correct than using ST_Buffer. Also see Paul Ramsey`s post.

FROM buildings AS b
WHERE ST_DWithin(b.geom,
  • So this query runs. But it returns no results. How would I go about debugging this query?
    – Abraham P
    Jun 16, 2017 at 8:46
  • So what does the 4326 SRID mean? When I looked up my original .prj files (I imported .shp files from the same directories here): prj2epsg.org/search I get PROJCS["British_National_Grid",GEOGCS["GCS_OS..... Running ` SELECT srid, proj4text FROM spatial_ref_sys WHERE srtext LIKE '%British_National_Grid%';` produces two results, 27700 and 7405. Neither one of them fixes the query.
    – Abraham P
    Jun 16, 2017 at 9:15
  • this should almost certainly be latitude, longitude in the make point
    – Ian Turton
    Jun 16, 2017 at 10:09

Your Answer

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

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