Hi Mario,

I'm surprised with your results. That's what I get with Shapely 1.0.12 :

>>> from shapely.geometry import Point
>>> from shapely.geometry.polygon import LinearRing
>>> test = LinearRing(((1,1),(2,3),(4,2),(3,0)))
>>> points = [ Point((2,2)),Point((1,0.5)),Point((1.5,0.5)) ]
>>> map(test.intersects,points)
[False, False, False]
>>> map(test.contains,points)
[False, False, False]

But, don't forget that a LinearRing instance is a 1D object/shape.
So your "test" LinearRing is different from a Polygon whose outer ring is
"test" :

 >>> from shapely.geometry import Polygon
>>> poly = Polygon(((1,1),(2,3),(4,2),(3,0)))
>>> map(poly.intersects,points)
[True, False, False]
>>> map(poly.contains,points)
[True, False, False]

Pascal

2009/5/7 Mario Ceresa <[email protected]>

> Hello everybody,
> I'm sorry to ask a very stupid question, but I don't undestand well
> how intersects and contains work:
>
> >> test = LinearRing([(1,1),(2,3),(4,2),(3,0)])
> >> points = [Point(2,2),Point(1,0.5),Point(1.5,0.5)]
> >> map(test.intersects,points)
> returned [True, True, True] and I was expecting [True,False,False]
> >> map(test.contains,points)
> returned [False, False, False] and I was expected [True,False,False]
>
> It may be that I'm thinking at the wrong geometry but why (1;0.5) and
> (1.5;0.5) are considered intersected with the polygon if they are
> outside? Is the intersection done with the bounding box of the
> objects?
>
> Is there any way to retrieve the points contained within the polygon?
>
> I'm using Shapely-1.0.12-py2.5 and geos 3.1 on a x86_64 Fedora 9
>
> Thanks and regards,
>
> Mario
> _______________________________________________
> Community mailing list
> [email protected]
> http://lists.gispython.org/mailman/listinfo/community
>
_______________________________________________
Community mailing list
[email protected]
http://lists.gispython.org/mailman/listinfo/community

Reply via email to