This fails. I don't think it should. I could be mistaken though.
from shapely.geometry import Point, Polygon
import shapely.prepared
point = Point(0.95, 0.05)
geom = Polygon([(0, 0), (1, 0), (0, 1), (0, 0)])
assert shapely.prepared.prep(geom).contains(point) == geom.contains(point)
>>> shapely.__version__
'1.6b4'
I'm on linux. I've installed Shapely from conda-forge.
I'm on linux. I've installed Shapely from conda-forge
We (conda-forge
) never packaged '1.6b4'
:confused:
Well then, I've probably source installed?
On Wed, Sep 6, 2017 at 9:29 AM, Filipe notifications@github.com wrote:
I'm on linux. I've installed Shapely from conda-forge
We (conda-forge) never packaged '1.6b4' 😕
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/Toblerity/Shapely/issues/519#issuecomment-327483368,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AASszHybaAEmRG3_axcG23VQ3Afem1Avks5sfp5RgaJpZM4POXVR
.
Sorry, 1.5.17post1
In [1]: import shapely
In [2]: shapely.__version__
Out[2]: '1.5.17.post1'
In [3]: from shapely.geometry import Point, Polygon
...: import shapely.prepared
...:
...: point = Point(0.95, 0.05)
...: geom = Polygon([(0, 0), (1, 0), (0, 1), (0, 0)])
...:
...: assert shapely.prepared.prep(geom).contains(point) == geom.contains(point)
...:
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-3-91a2da531b6f> in <module>()
5 geom = Polygon([(0, 0), (1, 0), (0, 1), (0, 0)])
6
----> 7 assert shapely.prepared.prep(geom).contains(point) == geom.contains(point)
AssertionError:
I can reproduce this. Perhaps this is a bug in GEOS?
(I didn't mean to close this...)
Yes, I'm seeing the same thing when I bypass Shapely and go straight to the GEOS C-api in Cython.
FYI I just add https://github.com/Toblerity/Shapely/issues/519#issuecomment-327484168 as a test to the shapely
feedstock and built with geos 3.6.0
, 3.6.1
, and 3.6.2
and they all fail :unamused:
I distribute GEOS 3.4.2 with the shapely wheels that I put on PyPI and can't reproduce the issue with that older version.
>>> shapely.geos.geos_version
(3, 4, 2)
>>> shapely.prepared.prep(geom).contains(point)
True
My error was on 3.5.1
(geopandas) mrocklin@carbon:~$ conda list | grep geos
geos 3.5.1 1 conda-forge
I've created a ticket upstream: https://trac.osgeo.org/geos/ticket/841. @mrocklin @snorfalorpagus can you confirm that I reported correctly?
geos 3.4.2
works for the conda package too. But we cannot afford to downgrade to that version :unamused:
Looks good to me. Thanks for going through the effort of raising upstream @sgillies
This seems to be a wontfix and I've closed the upstream issue. Strictly speaking, the point is on the boundary of the polygon and thus is not contained. Due to numerical precision issues, it may be computed to not be on the boundary, and that's what I see in my test. Something has changed since 3.4.2, but the results are actually more correct for one of the polygons. I didn't note above whether it was prep(geom).contains(point)
or geom.contains(point)
that was False
with GEOS 3.5.1.
Most helpful comment
This seems to be a wontfix and I've closed the upstream issue. Strictly speaking, the point is on the boundary of the polygon and thus is not contained. Due to numerical precision issues, it may be computed to not be on the boundary, and that's what I see in my test. Something has changed since 3.4.2, but the results are actually more correct for one of the polygons. I didn't note above whether it was
prep(geom).contains(point)
orgeom.contains(point)
that wasFalse
with GEOS 3.5.1.