[postgis-users] Buffer on linestring
Brent Wood
pcreso at pcreso.com
Fri Jan 5 12:05:57 PST 2007
--- Nicolas Ribot <nicky666 at gmail.com> wrote:
> > Hello,
> >
> > I 've strange results with using buffer on linestring.
> >
> > When I tried to extract streets segments contains in the buffer, I've these
> > results:
> >
> > select * FROM streets_db_edges_big_3 where
> > the_geom && buffer(setsrid(makeline('POINT(-1.68445
> 48.10753)','POINT(4.8291
> > 45.75936)'),4326),0.1,1)
> >
>
<snip>
As well as Nicolas's suggestion below, you are also returning points in an area
buffered by 0.1 degrees. (The native unit of data in the 4326 - WGS84 -
projection). I'm not sure if this is what you want or not. As a degree in
reality (but not in this query) is a different size at different latitudes,
your buffer areas will be distorted, with more distortion the further from the
equator.
For this query to be robust, you should reproject to an appropriate equal area
projection before buffering, & apply the same reprojection to your the_geom
field as well before checking for containment. As these are not indexed spatial
geometries, and the buffer polygons only have a few points, using the &&
operator may not give you much performance gain, and may actually slow things
down.
It may be more efficient to transform your linestring & point to an equidistant
projection, and select those points with a distance less that 0.1 (or its
equivalent in map units), instead of buffering the polygon & testing for
containment.
Cheers,
Brent Wood
> Hi Eric,
> You are using the && operator to restrict your search. This operator
> only works on objects' bbox.
> So you are not searching for objects inside your corridor, but inside
> the corridor's bbox, which is much bigger.
>
> Add an operator working on objects in your first query, something like:
>
> select *
> FROM streets_db_edges_big_3
> where
> the_geom && buffer(setsrid(makeline('POINT(-1.68445
> 48.10753)','POINT(4.8291 45.75936)'),4326),0.1,1)
> and intersects(the_geom, buffer(setsrid(makeline('POINT(-1.68445
> 48.10753)','POINT(4.8291 45.75936)'),4326),0.1,1))
>
> Choose the right operator to find candidates (intersects, overlaps, etc.).
>
> Nicolas
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
More information about the postgis-users
mailing list