[postgis-users] Bounding Box intersection

Mike Toews mwtoews at gmail.com
Sat Jul 14 02:26:25 PDT 2012


On 14 July 2012 00:35, Ed Linde <edolinde at gmail.com> wrote:
> Hi All,
> I have a table with linestring geometries, and I have the co-ordinates of a
> rectangle/ bounding box.
> I want to get only a restricted set of geometries that lie within or
> intersect with this box. Is there a
> way to construct this box on the fly and get only the relevant set of
> geometries?

Hi Ed,

You could use ST_MakeEnvelope [1] to make a box on the fly:

SELECT *
FROM roads
WHERE geom && ST_MakeEnvelope(10, 10, 11, 11, 4326);

-Mike

[1] http://postgis.refractions.net/docs/ST_MakeEnvelope.html



More information about the postgis-users mailing list