[postgis-users] Buffer on linestring

Nicolas Ribot nicky666 at gmail.com
Fri Jan 5 03:18:30 PST 2007


> 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)
>

> 126599 records
>
>
> If I did the thame thing with a Box3D with 0.1 degree more around my
> reference points:
>
> select  * FROM streets_db_edges_big_3    where
> setsrid('BOX3D(-1.78448 45.65923,4.92955 48.20667)'::BOX3D,4326)  &&
> the_geom
>
> 127449 records
>
> I don't understand why the difference between the 2 results is so short. The
> first query should return something like a corridor with less result. The
> area of selection  should be more restrict than for the BoxD.
>
> If I look at the polygon extract with astext:
>
> select  astext(buffer(setsrid(makeline('POINT(-1.68445
> 48.10753)','POINT(4.8291 45.75936)'),4326),0.1,1))
>
> result:
> "POLYGON((4.86301403403245 45.8534335791583,4.92317357915826
> 45.7254459659676,4.79518596596755 45.6652864208417,-1.71836403403245
> 48.0134564208417,-1.71836403403245 48.0134564208417,-1.77852357915826
> 48.1414440340324,-1.65053596596755 48.2016035791583,4.86301403403245
> 45.8534335791583))"
>
>
> area =1.4
>
> for the Box3D:
> select astext(setsrid('BOX3D(-1.78448 45.65923,4.92955
> 48.20667)'::BOX3D,4326))
>
> result:
> "POLYGON((-1.78448 45.65923,-1.78448 48.20667,4.92955 48.20667,4.92955
> 45.65923,-1.78448 45.65923))"
>
> area=17.1
>
>

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



More information about the postgis-users mailing list